BookmarkSubscribeRSS Feed
Deepti44
Fluorite | Level 6

Hi,

 

I'm trying to send an email with output  and email content to  valid userid see below  :

 

when i'm using set statement , my contents in the emial is not getting displayed i from the "else" part , any idea where i'm doing worng !

 

filename mailbox email;
data _null_;
set my_log1;
if &sysuserid='uvm472' then do ;
file mailbox to="Deepti@yahoo.com" subject='deepti test';
put _all_;
end;
else do;
file mailbox to="Deepti@yahoo.com" subject='not deepti test';
put " pbdv report is successfull";
end;

run;

1 REPLY 1
RickAster
Obsidian | Level 7

I see three things I would encourage you to look at.

  1. Comparing a macro variable to a character constant in a data step IF statement is probably not what you want. I don't know what the value of &SYSUSERID would be, but supposing it is something like USER100, this would be a word that SAS would treat as a variable name. Then the results of this would depend on whether there is a variable called USER100 in the data set MYLOG1.
  2. When a data step contains multiple FILE statements with the same fileref (MAILBOX in this example) containing options, I believe the data step consolidates those options the same as if they all appeared in one statement. This means you can't use IF-THEN statements to control FILE statement options.
  3. To use a data step to control email options or to send more than one message from one data step it is usually necessary to use email directives. For example, you might write
    put '!em_to! ' to_email;
    to set the recipient based on the value of a data step variable. For the details of the directives, see "PUT Statement Email Directives" at http://support.sas.com/documentation/cdl/en/lestmtsref/69738/HTML/default/viewer.htm#n0ig2krarrz6vtn....

Sorry for the short reply. I hope some of this helps.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1 reply
  • 889 views
  • 0 likes
  • 2 in conversation