Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

doing multiple runs using Macro 1

Status
Not open for further replies.

swtnamja

Technical User
Mar 4, 2009
2
US
Hi, I am trying to do multiple runs using
different variables each time and I was wondering
if I can use macro to automate it.

For example, I am trying to do:

proc gplot data=dat;
plot a * b;
run;
proc gplot data=dat;
plot c * d;
run;
proc gplot data=dat;
plot e * f;
run;
proc gplot data=dat;
plot a * e;
run;
proc gplot data=dat;
plot b * f;
run;

so on and so forth...

I am wondering rather than typing the run over and over,
if there is a way to designate list of variables to
marcro and let it run on its own.

I am a beginning sas user and not familiar with macros.
I appreciate your help. Thanks.
 
You dont need a separate proc statement for each plot you want to produce. You could simply...

proc gplot data=dat;
plot a*b a*c a*d b*c b*d c*d;
run;
 
Thanks for the reply, Medvedeff.

My codings are more complicated than that,
so here are some of the codes.

proc gplot data=semtech.&dataset._qa;
plot EV_std * time_dec iflow_ex_temp * time_dec /
overlay grid haxis=axis1 vaxis=axis2 legend=legend1;
axis2 label=(font=swiss height=1.3 rotate=0 a=90 'Exhaust Mass Flowrate, SCFM') minor=none;
label EV_std = 'Mass Flow, SCFM'
iflow_ex_temp = 'Flow Temp, deg C';
title1 height=1.15 "Exhaust Mass Flowrate";
title2 height=1.15 "&dataset";
run;

proc gplot data=semtech.&dataset._qa;
plot iambii_co2 * time_dec / grid haxis=axis1 vaxis=axis2;
axis2 label=(font=swiss height=1.3 rotate=0 a=90 'CO2 dry, %') minor=none;
title1 height=1.15 "CO2 Concentrations";
title2 height=1.15 "&dataset";
run;

proc gplot data=semtech.&dataset._qa;
plot iambii_co2 * time_dec icmass_flow * time_dec /
overlay grid haxis=axis1 vaxis=axis2 legend=legend1;
axis2 label=none minor=none;
label iambii_co2 = 'CO2(%)'
icmass_flow = 'EFM Mass Flow (kg/h)';
title1 height=1.15 "Time Alignment";
title2 height=1.15 "&dataset";
run;

I would have to produce 20-30 plots like this, but I was wondering if I can use macro to do the work instead of typing.

 
Easiest way to do this is to set up one step first, then take out the parameters and replace them with macro variables, then wrap it in a macro step.
For instance...
Code:
%macro dograph(DATASET);
  proc gplot data=semtech.&dataset._qa;
      plot EV_std * time_dec iflow_ex_temp * time_dec / 
              overlay grid haxis=axis1 vaxis=axis2
              legend=legend1;
      axis2 label=(font=swiss height=1.3 rotate=0 
            a=90 'Exhaust Mass Flowrate, SCFM') minor=none;
      label EV_std = 'Mass Flow, SCFM'
          iflow_ex_temp = 'Flow Temp, deg C';
      title1 height=1.15 "Exhaust Mass Flowrate";
      title2 height=1.15 "&dataset";
  run;
%MEND dograph;

%dograph(dat);
That should do it, then all you need to do is identify any other parameters that need to be taken out, such as titles, and add them to the macro definition...

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top