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 !

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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