%let var_list = n1 n2 n3;
data A;
call streaminit(123); /* set random number seed */
do i = 1 to 100;
n1 = rand("Normal");
n2 = rand("Normal");
n3 = rand("Normal");
output;
end;
run;
Suppose I want to filter a data set based on marco variable "&var_list", filtering all the data where each value in the macro variable is greater than 0. How should I write the macro?
Thanks for your help!
答案 0 :(得分:1)
你的意思是你想找到N1,N2和N3都是正数的记录吗?
data want ;
set have ;
if nmiss(of n1 n2 n3)=0 and min(of n1 n2 n3)>0;
run;
转换为使用宏变量。
%let varlist=n1 n2 n3;
data want ;
set have ;
if nmiss(of &varlist)=0 and min(of &varlist)>0;
run;