- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 08-13-2020 08:55 AM
(722 views)
I am trying to write a macro that puts a prefix inside all quoted strings in a list. It does work, but throws Note 49-169 for all prefix that seem not to make sense to SAS.
%macro prefixstrings(stringlist, prefix);
%sysfunc(prxchange(s/\'(\w+)/'&prefix$1/,-1,&stringlist))
%mend;
%put %prefixstrings(unquoted test 'quoted test', x);
/* no complaints because apparently '...'x is detected as having a meaning */
%put %prefixstrings(unquoted test 'quoted test', A);
/* NOTE 49-169 ... :-( */
Is there an easy workaround to avoid this? Putting a blank before &prefix is no option since the result is undesired.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Put the initial quote into a look-behind assertion, like this:
%macro prefixstrings(stringlist, prefix);
%sysfunc(prxchange(s/(?<=%str(%'))(\w+)/&prefix$1/,-1,&stringlist))
%mend;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Nice workaround, thank you 🙂
I secretly hoped it would be possible to forbid SAS macro compiler to look too deeply into the code it is meant to produce, but this one does the current job, definitely.
I secretly hoped it would be possible to forbid SAS macro compiler to look too deeply into the code it is meant to produce, but this one does the current job, definitely.