There is no such thing as a macro array. You can simulate arrays in macros in two ways: As you did, put the stuff into a single string, with a delimiter (blank in your case). Generate a number of macro variables with the same prefix. In case one, you can use the %SCAN macro function, (or, if you have quoted delimiters, %sysfunc(SCAN()) with the Q option) to access individual elements, in your case %put %scan(&numVarlist,1,str( )); You could also use the second solution: proc SQL;
select distinct variable into: numVar1-numVar999 from Map_num: In which case you can get the first element like this: %put &numVar1; Or, if you are using macro variables to access the "array": %let i=1;
%put &&numVar&i; The double ampersand works like this: the macro interpreter scans the codes several times. Each time, double ampersands become single ampersands, and "unmatched" ampersands trigger interpretation of variables. So, after the first scan, &&numVar&i becomes &numVar1, in the second scan that becomes the value (var1 in your example). When using the first method, you can use the COUNTW function to find the number of values, with the second option, it is not so obvious (you may look at which macro variables exist, but then, they may be variables generated in an earlier, similar SQL call). So in any case I advice you to store the value of the SQLobs macro variable after the SQL call: proc SQL;
select distinct variable into: numVar1-numVar999 from Map_num:
%let nVars=&SQLobs;
... View more