DATA Step, Macro, Functions and more

Macro Not getting resolved

Reply
Frequent Contributor
Posts: 87

Macro Not getting resolved

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);

Super Contributor
Posts: 408

Re: Macro Not getting resolved

[ Edited ]

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.

Super User
Posts: 5,092

Re: Macro Not getting resolved

Using the same tools already suggested, you can get:

 

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

Ask a Question
Discussion stats
  • 2 replies
  • 193 views
  • 0 likes
  • 3 in conversation