%let student_age=15 ;
proc print data=sashelp.class;
var &student_age _numeric_ ;
run;
What do you want to do?
Please describe your question clearly.
If you want to filter by age, you can do it with where.
%let student_age=15 ;
proc print data=sashelp.class;
where age=&student_age;
var _numeric_ ;
run;
What do you want to do?
Please describe your question clearly.
If you want to filter by age, you can do it with where.
%let student_age=15 ;
proc print data=sashelp.class;
where age=&student_age;
var _numeric_ ;
run;
It seems you forgot to ask a question.
Enabling the option mprint is recommend to see the code that was generated.
@BrahmanandaRao wrote:
%let student_age=15 ; proc print data=sashelp.class; var &student_age _numeric_ ; run;
There are a number of errors here. One is that you did not ask a question.
Another error is that when you use macro variables, and run the code, the value of the macro variable replaces the macro variable itself, and this replacement must produce legal valid working SAS code. Here is your code when I replace the value of the macro variable in place of the macro variable itself.
proc print data=sashelp.class;
var 15 _numeric_ ;
run;
So, is this valid legal working SAS code that does what you want? It is not valid working SAS code. Can you see why?
When working with macro variables, you must first create code that works without macro variables for one specific value (in this case 15). You did not do that. Since you don't have working code without macro variables, it will never work with macro variables either. Many people ignore this advice ... please don't be one of those people.
Last error: your title says you are using a macro, but you are not, you are using a macro variable. Macros and macro variables are not the same thing. Do not call macro variables by the term macro.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.