Here is a macro that I use that also puts everything you might need into macro variables. (I have just improved it a bit by stealing Tom's idea of using countw). %MACRO makelist(base,list); * create a set of macro variables named base1, base2 ... with values from list + list returned as <base>list; %PUT &base &list; %GLOBAL n&base &base.list; %LET &base.list =&list; %LET n&base=%sysfunc(countw(&list)); %DO i=1 %TO &&n&base; %GLOBAL &&base&&n&base; %LET &&base&&n&base=%SCAN(&list,&&n&base); %END ; ; %PUT n&base = &&n&base; %DO i=1 %TO &&n&base; %PUT &base&i &&&base&i; %END; %MEND; %makelist(test,D1 D2 D3); Then you can reference them with a loop in a macro eg. ... PROC MEANS; VAR &testlist; * D1 D2 D3; OUTPUT OUT=testmeans MEAN=%DO I=1 %TO &ntest; &&test&i..m %END; ; The output dataset contains means in the variables D1m D2m and D3m.
... View more