libname fsystem '/user/data/lives/here';
filename report email "person1@yahoo.com";
data fsystem.dset3;
merge fsystem.dset1 fsystem.dset2;
if var1=var2 then do;
put 'Variables are equal';
put 'var1=' var1 'var2=' var2;
call system ('sas /progs/live/here/prog1.sas');
end;
else do;
file report
to=('person1@yahoo.com'
'person2@yahoo.com')
subject="NOTIFICATION EMAIL"
type='text/html'
attach=("/user/data/lives/here/prog1.log");
put 'Variables are unequal"
put 'var1=' var1 'var2=' var2;
end;
run;
I would like to conditionally send an email when var1 DOES NOT EQAUL var2. However, the email currently gets sent regardless of whether or not the two variables are equal. How can I fix this issue? Please advise. Thanks.
Something like:
/* Macro has the send mail bits in it */ %macro SendMail (); data _null_; ... run; %mend SendMail; data _null_; set ???; if var1=var2 then call system (...); else call execute('%SendMail;'); run;
Note you do not appear to set any dataset in the data fsytem... datastep, therfore there is no var1 or var 2. You do have two output datasets, which never get used?
data fsystem.dset1 fsystem.dset2;
if var1=var2 then do;
Since there is no set statement, and no other means from which var1 and var2 could get a value, both will be missing and therefore equal. Always.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.