Hi,
I have a model I would like to run with with a series of independent and dependent variables. I have written a macro to do this. Some of the independent variables are categorical, thus, I included these variables in the class statement. However, I realized that putting unused variables in class statement limits sample for each analysis because the observations used in the regression are limited to those with values for all class statement variables. How can i fix this? Also, any suggestions to make code more efficient would be helpful. My list after %mend is VERY long. Thanks.
code sample:
%macro model(dep, indep);
proc glm data=data1 ;
class var2 (ref=first) indep1 (ref=first) indep2 (ref=first)indep3 (ref=first) indep4 (ref=first) indep5 (ref=first);
model &dep= &indep var2 var3 var4/solution;
run;
%mend;
%model(dep1, indep1);
%model(dep1, indep2);
%model(dep1, indep3);
%model(dep1, indep4);
%model(dep1, indep5);
%model(dep2, indep1);
%model(dep2, indep2);
.....
Thanks in advance!
How about :
%macro model(dep, indepc, indep);
proc glm data = data1 ;
class var2 &indepc / ref = first;
model &dep = &indep &indepc var2 var3 var4 / solution;
run;
%mend;
you would specify one of indepc or indep in your macro call, depending if your variable is categorical or not.
%model(dep1, indep4, );
or
%model(dep2, , indep99);
How about :
%macro model(dep, indepc, indep);
proc glm data = data1 ;
class var2 &indepc / ref = first;
model &dep = &indep &indepc var2 var3 var4 / solution;
run;
%mend;
you would specify one of indepc or indep in your macro call, depending if your variable is categorical or not.
%model(dep1, indep4, );
or
%model(dep2, , indep99);
Oh, good idea. This works! Thank you.
The CLASS statement doesn't require a variable, it can be empty.
ie the following won't affect your output, where the macro variable is blank.
%let indepn=;
proc glm data=...;
CLASS &indepn;
...
run;quit;
Oh I see. Didn't think of calling up the macro variable in the Class statement. Will try. 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.