/*************************************************** slist: an abbreviated list of variable names can be any SAS variable list flist: a global macro variable that is the expanded variable name list ***************************************************/ %macro varlist(data, slist); data _tiny_; set &data; keep &slist; run; proc sql noprint; select name into :myvarlist separated by " " from sashelp.vcolumn where libname="WORK" and memname="_TINY_"; quit; %let flist = &myvarlist; %mend;
data test; array v(10); do j = 1 to 5; do i = 1 to 10; v(i) = i*5*j; ind = (i*j >30); end; output; end; run;
%global flist; %varlist(test, v:); %put &flist;
122 %put &flist; v1 v2 v3 v4 v5 v6 v7 v8 v9 v10