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

Hi 

I stored some where statements into a macro variable separated by '# ' and I'd like to scan the statement out one by one for deriving a new variable.
Below is a simple example but failed

%let whr=%str(TYPE eq 'A'#TYPE eq 'B'#TYPE eq 'C'#TYPE eq 'D');
%let x=%scan(&whr,1,'#');

%put &x;

When I tried to %put &x, only 'TYPE eq' was displayed in log.

Does anyone can give a hand? Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

You are telling SAS that the single quote is a separator, so SAS obeys.

 

This works:

 

%let x=%scan(&whr,1,#);

 

View solution in original post

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

You are telling SAS that the single quote is a separator, so SAS obeys.

 

This works:

 

%let x=%scan(&whr,1,#);

 

Kurt_Bremser
Super User

Background: the macro language is a text processor and knows no other datatype, so quotes are not needed to identify strings. Instead they will become part of the "data".

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 930 views
  • 0 likes
  • 3 in conversation