I have a macro variable named &_badFileName. It contains the value &cmpn_cd_YYYYMMDD_TEST_DONT_LOAD. The code runs in open code, not a macro.
I need to print the text vallue of the macro variable in an error message _without_ the value of &cmpn_cd being resolved. I want to see the string &cmpn_cd_YYYYMMDD_TEST_DONT_LOAD in my error message.
I've tried all of the quoting function I can think of.
I've tried nesting some of the functions.
I've tried using quoting functions in a %let statement to reassign the value of &_badFileName there instead of in the putlog statement.
But they either try to resolve &_badFileName and return the Error seen below below or prevent resolution of &_badFileName so that &_badFileName prints in the message as text.
It seems to me that I need a quoting function that masks resolution at execution. I'm sure I'm missing something simple, but Help will be greatly appreciated. Thanks in advance.
9707 data _null_;
19708 putlog '-----';
19709 putlog "USER-DEFINED ERROR: At least 1 Output File Name in the &_excelWorkbookName Output_Fields worksheet is
19709! bad.";
19710 putlog ' It must contain a valid date formatted as YYYYMMDD.';
19711 putlog " The bad Output File Names are %nrbquote(&_badFileNames)..";
ERROR: Symbolic variable name CMPN_CD_YYYYMMDD_TEST_DO_NOT_LOAD must be 32 or fewer characters long.
19712 putlog '-----';
19713 run;
run;
Have you tried:
putlog " The bad Output File Names are %superq(_badFileNames).";
Note that the & is removed ... it's supposed to be that way.
Good luck.
data _null_;
call symputx('_badFileName','&cmpn_cd_YYYYMMDD_TEST_DONT_LOAD');
stop;
run;
data _null_;
badfile=symget('_badFileName');
putlog "The bad Output File Names are " badfile;
stop;
run;
...or this way:
data _null_;
putlog "The bad Output File Names are %superq(_badFileName)";
stop;
run;
Astounding, that's it!! %SUPERQ() doesn't want the & for the macro variable. I knew I was missing something simple.
Patrick, Thanks for a workable second solution. Sometimes I get so fixated on a specific solution that I don't stop, take a breath, and consider alternatives. If I could give you both Correct Answer credit I would, but Astounding was first by a few minutes.
John
If you really must have the &:
%let _badFileName = %nrstr(&cmpn_cd_YYYYMMDD_TEST_DONT_LOAD);
data _null_;
putlog "&_badFileName";
run;
Have you tried:
putlog " The bad Output File Names are %superq(_badFileNames).";
Note that the & is removed ... it's supposed to be that way.
Good luck.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.