BookmarkSubscribeRSS Feed
ijmoorejr
Calcite | Level 5
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.

 

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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?

Kurt_Bremser
Super User
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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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