BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bentleyj1
Quartz | Level 8

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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.


View solution in original post

4 REPLIES 4
Patrick
Opal | Level 21

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;

bentleyj1
Quartz | Level 8

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

SASKiwi
PROC Star

If you really must have the &:

%let _badFileName = %nrstr(&cmpn_cd_YYYYMMDD_TEST_DONT_LOAD);

data _null_;

putlog "&_badFileName";

run;

Astounding
PROC Star

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.


hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3340 views
  • 3 likes
  • 4 in conversation