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.


sas-innovate-2024.png

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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