a week ago - last edited a week ago
%macro vars(first=1,last=); %global gfirst glast; %let gfirst=&first; %let glast=&last; var test&first-test&last; %mend vars; %put &gfirst; proc print; %vars(last=50) title "Analysis of Tests &gfirst-&glast"; run; PROC PRINT; VAR TEST1-TEST50; TITLE "Analysis of Tests 1-50"; RUN;
a week ago
a week ago
When you use syntax like:
Then Proc Print, or other Procedure, will assume that you want to use the last created data set as input.
If your current session has not created any data set then you get that error.
While SAS is helpful about making guesses for things like the last data set it is very poor practice to rely on those guesses.
I would also suggest passing a "stem" value for the variable list to make the macro a little more useful
%macro vars(stem=test,first=1,last=); %global gfirst glast; %let gfirst=&first; %let glast=&last; var &stem.&first-&stem.&last; %mend vars;
Then you could create a list of any varaibles that start with a common name portion.
But the data set you attempt to print or process has to have those variables in it and really should be named.