|Date: ||Tue, 15 Apr 2003 11:57:05 -0400|
|Reply-To: ||praetor <praetor@MEDSTAT.COM>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||praetor <praetor@MEDSTAT.COM>|
|Subject: ||FW: SAS EMAIL in the if-then DO statement|
This message was quarantined due the word nasty in the text and is being
forwarded by Medstats e-mail administrator.
From: David L. Cassell [mailto:cassell.david@EPAMAIL.EPA.GOV]
Sent: Monday, April 14, 2003 6:42 PM
Subject: Re: SAS EMAIL in the if-then DO statement
"Workman, Rob" <Rob.Workman@CARBOMEDICS.COM> sagely advised:
> Another option is to use macros if that is more familiar to you. Here
> %macro eml(state);
> %if &state = TX %then
> . . . . . .
While I never disagree with Rob (:-)) I will recommend here that you write
your code as
%if "&STATE." = "TX" %then
instead. I believe Ron Fehd was the first to point out in SAS-L the dangers
inherent in mixing state codes and macro code. After all, what happens when
your state is Oregon, or Nebraska?
Answer: Bad Things.
Your code becomes
%if &state = OR %then
and the macro compiler parses that as
%if (&state = ) or () %then
and you get a nasty but confusing error message. Since Nebraska has NE
(that's Not Equal) for its state code, it can cause problems as well.
In addition, I thought I would point out that SAS does not handle socket
connections particularly well. So when there is a problem with the
connection to your Mail Transport Agent of choice, you just get a failure
with a cryptic error message. For this reason, I still prefer to use Perl
for my email processes, even when monitoring SAS programs. I would also
recommend Python for this task. Either langauge has sufficient
error-handling to allow you to deal with email glitches.
David Cassell, CSC
Senior computing specialist