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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.