BookmarkSubscribeRSS Feed
Calcite | Level 5
libname fsystem '/user/data/lives/here';
filename report email "";

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/'); end; else do; file report to=('' '') 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.


Diamond | Level 26 RW9
Diamond | Level 26

Something like:

/* Macro has the send mail bits in it */
%macro SendMail ();
  data _null_;
%mend SendMail;

data _null_;
  set ???;
  if var1=var2 then call system (...);
  else call execute('%SendMail;');

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?

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.


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
  • 3 in conversation