hello,
%macro mc_email (to=, from=, cc=, subject=, sender=, texte=, expediteur=, attach=) ;
DATA _null_ ;
slept= sleep(120);
run;
data _null_;
filename mail email to=(&to.) from=&from.
cc=(&cc.)
subject=&subject.
sender=&sender.
ATTACH= (&attach.)
;
file mail;
put 'Bonjour,' ;
put ' ' ;
put "&texte." ;
put ' ' ;
put 'Cordialement,' ;
put ' ' ;
put "&expediteur." ;
run;
%mend mc_email ;
%mc_email( to = &mv_email_destinataire_list,
from = "Mr Nasser",
cc = &mv_email_copie_list,
subject = "Execution ra_retention : OK",
sender = "lauch_ra_retention.sas",
texte = Le programme s est déroulé sans erreur,
expediteur = Mr Nasser ,
attach= );
I call this macro by specifiying a file in the "attach" option--> it works
I call this macro by NOT specifiying a file in the "attach" option--> it DOES NOT works.
What could I do to make this macro working for both options ("attach" fill in or not) ?
thanks a lot in advance for your help
You can omit the double quotes:
%if &attach. ne %then %do;
ATTACH= (&attach.)
%end;
Use a condition:
data _null_;
filename mail email to=(&to.) from=&from.
cc=(&cc.)
subject=&subject.
sender=&sender.
%if "&attach." ne "" %then %do;
ATTACH= (&attach.)
%end;
;
Hello Kurt and thanks for your quick repsonse.
I test your solution.
without specifiied file, it works. but by specifying a file like
attach= "/home/ldap/mellouna/lance_prog_cdgr.log" I got an error message
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
"&attach." ne ""
You can omit the double quotes:
%if &attach. ne %then %do;
ATTACH= (&attach.)
%end;
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.
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.