I have an dataset variable x=p.q,r
these three letters seperated with a single comma.Now my requirement is i need to assign these values to macro variable.
There are three macro variables m1,m2,m3
i need output like m1=p
m2=q
m3=r
Can anybody give a solution and explanation.Thnk.............u
data _null_;
x='p,q,r';
call symputx('m1',scan(x,1));
call symputx('m2',scan(x,2));
call symputx('m3',scan(x,3));
run;
%put &m1 &m2 &m3;
data _null_;
x='p,q,r';
call symputx('m1',scan(x,1));
call symputx('m2',scan(x,2));
call symputx('m3',scan(x,3));
run;
%put &m1 &m2 &m3;
thanks .... Linlin.You gave me a code in easy pattern.
FWIW: Linlin's suggested code will also work with your example input, i.e.: p.q,r
As for the explanation you asked for, the scan function is described at: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.htm
and call symputx is described at: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002295697.htm
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.