BookmarkSubscribeRSS Feed
Deepti44
Fluorite | Level 6

Hi All,

 

How can i send a conditional email with different subject messages .Can you please help me out as im trying to execute my job in batch mode and trying to send emails based on success/unsuceesful of job ! i tried below but it is going to else statement even if the if statement is true.

FILENAME TEMP EMAIL TO=(
"person@yahoocom"
)
;

DATA _NULL_;
set my_log1;
IF &count1.=0 then do;
FILE TEMP
subject="PBDV report Successfull for &run_date." ;
PUT 'PLEASE VIEW THE REPORT IN THE REPORTING PORTAL ' ;
PUT ;
today = put(date(),worddate18.);
PUT ' ' today;
PUT ;
end;
else
do;
file temp
subject="PBDV report not Successfull for &run_date.";
PUT "PBDV REPORT FAILED FOR &run_date." ;
PUT ;
Put ' This e-mail is an automated notification!';
PUT ;
PUT 'DO NOT REPLY TO THIS MESSAGE ';
Put '=============================================';
Put ' Please contact:';
Put ' .person.@yahoo.com

' ;
Put ' if you have any questions or concerns.' ;
Put '=============================================';
Put ;
end;

RUN;

6 REPLIES 6
Patrick
Opal | Level 21

@Deepti44

With an IF..THEN ..ELSE as you've done it. 

What is not working?

Deepti44
Fluorite | Level 6

even IF statement is true , it is going to else staement and sending subject of the email  "as  job not successfull ".

Patrick
Opal | Level 21

@Deepti44

If you're testing with the code you've posted then I don't see how this could happen.

 

Are you sure your macro variable contains a 0 when you believe the condition should be TRUE?

 

Use options symbolgen; to see in the Log to what your macro var resolves;

 

For test purposes populate the macro variable manually right before the data step

%let count1=0;

 

 

 

Deepti44
Fluorite | Level 6

yes my count1 is resolving to 0, i have double checked but not sure why it is going to else part!

Deepti44
Fluorite | Level 6

I have used Email directives from SAS and it worked, i just replaced current subject with the new one's.

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 6 replies
  • 2084 views
  • 0 likes
  • 2 in conversation