Suppose you need to pass a variable in loop based on the input defined in a macro.
When you execute the above sas program, it generates the following statements :
proc means data = &input noprint nway;
class a;
vars b;
output out=out1 mean= median= / autoname;
run;
%macro report (input=, var = , class=);
%let n=%sysfunc(countw(&var));
%do i=1 %to &n;
%let val = %scan(&var,&i);
proc means data = &input noprint nway;
class &class;
vars &val;
output out=out&i mean= median= / autoname;
run;
%end;
%mend;
options mprint;
%report(input= test, var = b c, class=a);
When you execute the above sas program, it generates the following statements :
proc means data = &input noprint nway;
class a;
vars b;
output out=out1 mean= median= / autoname;
run;
proc means data = &input noprint nway;
class a;
vars c;
output out=out2 mean= median= / autoname;
run;
Hi deepanshu
ReplyDeleteWhat does sysfunc do????..does it convert into character value??
Sysfunc is used to apply functions within macro. You can use all functions of data steps by using sysfunc
Delete