DATA Step, Macro, Functions and more

Multiple values in a Macro variable

Accepted Solution Solved
Reply
Frequent Contributor
Frequent Contributor
Posts: 78
Accepted Solution

Multiple values in a Macro variable

Hello ,

 

May you help me to check how I should correct the following Macro statements? &med cannot provide me the correct value. :-( 

 

%let medlist = %str("cisplatin" ; "carboplatin"; "paclitaxel" ; "paclitaxel protein-bound" ; "pemetrexed disodium" );


%let med = %scan(&medlist, 4, ";") ;


%put &medlist &med ;

 

Thank you,

Ivy


Accepted Solutions
Solution
‎01-06-2017 01:44 PM
Contributor
Posts: 24

Re: Multiple values in a Macro variable

[ Edited ]

Hi.

 

Remove the " around ;

  

%let med = %scan(&medlist, 4, ;) ;

 

The third argument of the SCAN function is a list of characters considered to be separators, any of them will be identified as a separator.

 

If you want to remove the quotes around the item use dequote function, like this:

 

%let med = %sysfunc(dequote(%scan(&medlist, 4, ;))) ;

 

More on the SCAN function here: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.htm

 

Hope it helps.

 

Daniel Santos @ www.cgd.pt

View solution in original post


All Replies
Solution
‎01-06-2017 01:44 PM
Contributor
Posts: 24

Re: Multiple values in a Macro variable

[ Edited ]

Hi.

 

Remove the " around ;

  

%let med = %scan(&medlist, 4, ;) ;

 

The third argument of the SCAN function is a list of characters considered to be separators, any of them will be identified as a separator.

 

If you want to remove the quotes around the item use dequote function, like this:

 

%let med = %sysfunc(dequote(%scan(&medlist, 4, ;))) ;

 

More on the SCAN function here: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.htm

 

Hope it helps.

 

Daniel Santos @ www.cgd.pt

Frequent Contributor
Frequent Contributor
Posts: 78

Re: Multiple values in a Macro variable

Posted in reply to Daniel-Santos
Thank you very much, that works !
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 287 views
  • 2 likes
  • 2 in conversation