PUT with unmatched ( and macro variables.

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

PUT with unmatched ( and macro variables.

[ Edited ]

I'm trying to send an email if certain condition is met. The email content should be "Ooooo :-( your hh:mm prediction failed" where hh:mm should be the time value stored in a macro variable.Just out of curiosity, how can I make it work? I know the easiest way is just to change the content to "Prediction failed", no unmatched (, no macro variable involved. Thank you!

 

%macro send_email;
%if &email_ts_v2.<%sysevalf(%sysfunc(datetime())-30*60*0) %then %do;
filename mailbox email;
data _null_;
file mailbox
to='xxx@xxx.com'
from='xxx@xxx.com'
subject="xxx"
TYPE='TEXT/HTML';

put "Oooo :-( YOUR %superq(%sysfunc(putn(&max_time_60, HHMM5.))) PREDICTION PROCESS DID NOT RUN SUCCESSFULLY."/;

run;
%end;
%mend send_email;

%send_email;


Accepted Solutions
Solution
‎10-12-2015 02:41 PM
PROC Star
Posts: 1,324

Re: PUT with unmatched ( and macro variables.

Posted in reply to cloudyhill

Hi,

The unmatched parenthesis should not be a problem. That's allowed in a quoted string.  You do not need %superq().  The argument to %superq is the name of a macro variable, the resolved value of which you want to quote.  I think your code should work if you just remove the %superq().  Here is my test macro:

 

%macro test(max_time_60=100);
data _null_;
  put "Oooo :-( YOUR %sysfunc(putn(&max_time_60, HHMM5.)) PREDICTION PROCESS DID NOT RUN SUCCESSFULLY."/;
run;
%mend test;

And log:

192  %test()
MPRINT(TEST):   data _null_;
MPRINT(TEST):   put "Oooo :-( YOUR  0:02 PREDICTION PROCESS DID NOT RUN SUCCESSFULLY."/;
MPRINT(TEST):   run;

Oooo :-( YOUR  0:02 PREDICTION PROCESS DID NOT RUN SUCCESSFULLY.

View solution in original post


All Replies
Solution
‎10-12-2015 02:41 PM
PROC Star
Posts: 1,324

Re: PUT with unmatched ( and macro variables.

Posted in reply to cloudyhill

Hi,

The unmatched parenthesis should not be a problem. That's allowed in a quoted string.  You do not need %superq().  The argument to %superq is the name of a macro variable, the resolved value of which you want to quote.  I think your code should work if you just remove the %superq().  Here is my test macro:

 

%macro test(max_time_60=100);
data _null_;
  put "Oooo :-( YOUR %sysfunc(putn(&max_time_60, HHMM5.)) PREDICTION PROCESS DID NOT RUN SUCCESSFULLY."/;
run;
%mend test;

And log:

192  %test()
MPRINT(TEST):   data _null_;
MPRINT(TEST):   put "Oooo :-( YOUR  0:02 PREDICTION PROCESS DID NOT RUN SUCCESSFULLY."/;
MPRINT(TEST):   run;

Oooo :-( YOUR  0:02 PREDICTION PROCESS DID NOT RUN SUCCESSFULLY.
Occasional Contributor
Posts: 9

Re: PUT with unmatched ( and macro variables.

Thank you so much for the help! It works! 

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 239 views
  • 1 like
  • 2 in conversation