BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rawindar
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

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;

View solution in original post

3 REPLIES 3
Linlin
Lapis Lazuli | Level 10

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;

rawindar
Calcite | Level 5

thanks .... Linlin.You gave me a code in easy pattern.

art297
Opal | Level 21

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 796 views
  • 0 likes
  • 3 in conversation