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!
You are telling SAS that the single quote is a separator, so SAS obeys.
This works:
%let x=%scan(&whr,1,#);
You are telling SAS that the single quote is a separator, so SAS obeys.
This works:
%let x=%scan(&whr,1,#);
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".
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: