I use following to create a macro variable pattern so that it equals to %vs%:
%let pattern=%nrstr(%vs%);
%put pattern =&pattern;
But SAS gives error and warning:
WARNING: The quoted string currently being processed has become more than 262 characters long. You might have unbalanced quotation marks.
How to achieve the desired result?
The real issue is the second %. The way %nrstr works, as vs% it will assume you are masking the ) sign on %nrstr(%vs%) and thus leave you with open code.
You could do any of the following:
%let pattern=%nrstr(%vs% );
%let pattern=%nrstr(%vs%%);
%let pattern=%nrstr(%%vs%%);
I prefer the last one...
%let pattern=%nrstr(%%vs%%);
%put pattern=&pattern.;
pattern=%vs%
Note that %nrstr() will mask % sign, then why do we need doulbe percent sign like %% to achieve a %??
The real issue is the second %. The way %nrstr works, as vs% it will assume you are masking the ) sign on %nrstr(%vs%) and thus leave you with open code.
You could do any of the following:
%let pattern=%nrstr(%vs% );
%let pattern=%nrstr(%vs%%);
%let pattern=%nrstr(%%vs%%);
I prefer the last one...
Thanks very much, very good explanation.
Also why do we need a dot after &pattern?
You do not "need" it. You could just consider it my personal preference for coding style.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.