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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.