Why does this code still send an email when the condition to link to the email
send cannot get executed? SASLOG proves condition vale is zero put x=.
98 filename outbox email 'dan.xxxxx@zz.com';
99
100 data _null_;
/* Set variable */
101 x=0;
102 put x=;
/* condition cannot be true */
103 if x=1 then do;
104 link send_email; /* should only be hit if condition is true */
105 end;
106 return;
107
108 send_email: /* seems to get executed no matter what */
109 file outbox
110 to=("dan.xxxxx@zzcom")
111 subject="Email test";
112 put "Email test from SAS program";
113 put " ";
114 return;
115 run;
NOTE: The file OUTBOX is:
E-Mail Access Device
x=0
Message sent
To: ("dan.xxxxx@zz.com" )
Cc:
Bcc:
Subject: Email test
Attachments:
NOTE: 0 records were written to the file OUTBOX.
NOTE: DATA statement used (Total process time):
real time 7.22 seconds
cpu time 0.35 seconds
Without more background it’s hard to guess exactly how you are planning to do this but I think a cleaner approach would be to:
Step 1:
Step 2:
EDIT: Changed
returnstatement in the code to astopstatement.