%let name=ABCD efgh,ijkl mnop,qrst;
%put %scan(%nrbquote(&name),1,%nrbquote(,));
%let name=ABCD efgh,ijkl mnop,qrst;
%put %scan(%bquote(&name),1,%(,));
@Ksharp I think you're missing the STR. As written:
%scan(%bquote(&name),1,%(,));
would treat four characters as delimiters: % ( ) ,
It works because the () are enough to hide the comma from the macro processor during the macro call. But if the string has % or () in it, those characters will be delimiters.
1 %let name=ABCD% ef(gh,ijkl m)nop,qrst;
2 %put %scan(%bquote(&name),1,%(,));
ABCD
But with %STR(), it treats only one character as a delimiter: ,
3 %put %scan(%bquote(&name),1,%str(,));
ABCD% ef(gh
Yeah. I am sure I write %STR ,
%put %scan(%bquote(&name),1,%str(,));
But I don't know why it would appear this. Maybe this forum eat 'STR' .
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.