LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2007, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 29 Aug 2007 13:19:27 -0400
Reply-To:   Kevin Roland Viel <kviel@EMORY.EDU>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Kevin Roland Viel <kviel@EMORY.EDU>
Subject:   Re: SAS error checking
In-Reply-To:   <1188406135.062913.10540@q3g2000prf.googlegroups.com>
Content-Type:   TEXT/PLAIN; charset=US-ASCII

On Wed, 29 Aug 2007, Danger wrote:

> Thank You Kevin, > This is what i am doing: > > libname test "\\Sas-sjc-001\s\Atul\Model_Tables" ; > > > proc sort data = test.Crossref nodupkey out = test.test; > by model_id; > > run; > > > FILENAME test EMAIL 'me@me.com' > emailid = "Microsoft Outlook"; > %macro sendmail; > DATA testmail; > set test.test; > run; > > %if &syserr = 0 %then %do; > data _null_; > FILE test > SUBJECT= 'Data for review'; > PUT ' '; > PUT 'Attached you will find the updated dataset ready for your > review.'; > PUT ' '; > PUT 'Have a nice day,'; > > run; > %end; > %else %do; > data _null_; > FILE test > TO='me@me.com'; > SUBJECT= 'Error With Data'; > PUT 'ATTENTION PLEASE,'; > PUT 'There was an error when this program ran. Please check the > program and resubmit.'; > PUT ' '; > > run; > %end; > %mend sendmail; > %sendmail; > > The problem is &syserr is taking the output from the last observation > and sending the mail. (so if the first mail was a FAIL all preceeding > MAILS will also flag FAIL messeges. And vice-versa.

I don't think you need to tinker with the macro variables. Consider just the datastep and _ERROR_.

Online docs:

"_ERROR_ is 0 by default but is set to 1 whenever an error is encountered, such as an input data error, a conversion error, or a math error, as in division by 0 or a floating point overflow. You can use the value of this variable to help locate errors in data records and to print an error message to the SAS log.

For example, either of the two following statements writes to the SAS log, during each iteration of the DATA step, the contents of an input record in which an input error is encountered:

if _error_=1 then put _infile_;

if _error_ then put _infile_;"

If not, I will leave it to the macro gurus since I don't have a copy of SAS at work (hello Jim, Please? Pretty please?) with which to test it.

Good luck,

Kevin

Kevin Viel, PhD Post-doctoral fellow Department of Genetics Southwest Foundation for Biomedical Research San Antonio, TX 78227


Back to: Top of message | Previous page | Main SAS-L page