BookmarkSubscribeRSS Feed
helloSAS
Obsidian | Level 7

I’ve a macro question. In the below code &err is resolving to mdl_rc but I want it to resolve to mdl_rc=1. Can you suggest what I’m doing wrong here?

 

     %let mdl_rc=1; %put &mdl_rc;

 

           %macro systask_err(err);

                             %put &err;

                             %if &err > 1 %then %do;

                                  %put "it resolves to &err.";

                                  data _null_; file outbox to=("xxx@gmail.com")

                                  subject="&err systask failed";

                                  run;

 

                                *  endsas;

 

                             %end;

                             %else %do;

                                  data _null_; file outbox to=("xxx.gmail.com")

                                  subject="&err systask success";

                                  run;

                             %end;

 

                    %mend;

 

           *waitfor _all_ mdl;

 

             %systask_err(mdl_rc);

2 REPLIES 2
jklaverstijn
Rhodochrosite | Level 12

Hi @helloSAS,

 

I see two ways to get what you want (if I understand you correctly):

 

Either call the macro this way:

 

%systask_err(&mdl_rc);


or, inside the macro, use a triple ampersand in when referring to the value of mdl_rc and not its name:

 

%put "it resolves to &&&err.";

Hope this helps,

- Jan.

Astounding
PROC Star

Using the same tools already suggested, you can get:

 

%put It resolves to &err=&&&err..;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 809 views
  • 0 likes
  • 3 in conversation