BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Nasser_DRMCP
Lapis Lazuli | Level 10

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

1 ACCEPTED SOLUTION
4 REPLIES 4
Kurt_Bremser
Super User

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;
;
Nasser_DRMCP
Lapis Lazuli | Level 10

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 ""

 

Nasser_DRMCP
Lapis Lazuli | Level 10
It works perfectly thanks !

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1237 views
  • 0 likes
  • 2 in conversation