%macro analyst(inputfile); data a; infile "/home/grego1/STAT 540/&inputfile..txt"; input y x; run; proc sort data=a out=unique nodupkey; by x; run; /* Find the number of levels of X */ data _null_; set unique end=last; if last=1 then call symputx("XLevels",_n_); run; /* Compute a t-test for X with 2 levels */ %if &XLevels = 2 %then %do; proc ttest data=a; class x; var y; run; %end; /* ANOVA if X has more than 2 levels */ %else %if &Xlevels>2 %then %do; proc glm data=a; class x; model y=x; run; %end; /* No analysis when X has 1 level */ %else %do; proc univariate normal data=a; histogram y; var y; proc print data=a; footnote "No testing; X variable has only one level"; run; %end; %mend; %analyst(IFMacro2) %analyst(IFMacro4) %analyst(IFMacro1)