I have a macro variable which stores a string of names, for example:
%let operation = add subtract divide multiply;
I wanted to transpose each element (to appear as observation) in the macro into a data set variable. So the data set should look like:
<obs> <operation>
<1> add
<2> subtract
<3> divide
<4> multiply
Use the SCAN() function. The default delimiters will work for your example, otherwise you can specify the exact delimiters to use.
%let operation= add subtract divide multiply;
data want ;
length obs 8 operation $20 ;
do obs=1 by 1 until (operation=' ');
operation=scan("&operation",obs);
if operation ne ' ' then output;
end;
run;