Hi Team,
I wrote a macro and I feel it needs to be tiday. Too many dataset names. Could anybody help me look tidy.
Thanks
%macro age(dname1=,dname2=,dname3=,dname4=,dname5=);
proc means data=&dname1 nway noprint;
var age;
output out=&dname2 n= mean= std= median= min= max=/autoname;
run;
data &dname3;
set &dname2;
keep n meansd median minmax;
n=put(age_N,4.);
meansd=put(age_Mean,4.1)|| " ("||put(age_StdDev,4.1)||" )";
median=put(age_Median,4.1);
minmax=put(age_Min,4.1) ||"/"|| put(age_Max,4.1);
run;
proc transpose data=&dname3 out=&dname4;
var n meansd median minmax;
run;
data &dname5(drop=_name_);
set &dname4;
stat=put(_name_,$age.);
label="Age (Years)";
run;
%mend;
%age(dname1=one,dname2=two,dname3=three,dname4=four,dname5=five);
Karun,
My first question would be "Do you really need to write this as a SAS macro?" As written, it appears to be quite specific (i.e., not reusable for future tasks) and could easily be done outside of the macro language.
Second, for any code (in or out of macroland), you really should make use of indentation.
Third, do you need all five files or can one or more of them be re-used?
Art
Sorry...... i meant TIDY
Karun,
My first question would be "Do you really need to write this as a SAS macro?" As written, it appears to be quite specific (i.e., not reusable for future tasks) and could easily be done outside of the macro language.
Second, for any code (in or out of macroland), you really should make use of indentation.
Third, do you need all five files or can one or more of them be re-used?
Art
Hi Arthur,
There are 5 datasets which goes seperately into dname1(sorry for just putting only a part of my code here)
So I get to reuse it 5 times
Thanks
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.