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 (June 2007, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 15 Jun 2007 11:32:21 -0700
Reply-To:     "Pardee, Roy" <pardee.r@GHC.ORG>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Pardee, Roy" <pardee.r@GHC.ORG>
Subject:      Re: mistakes in SAS that don't generate errors
Comments: To: "ckxplus@yahoo.com" <ckxplus@YAHOO.COM>
In-Reply-To:  A<1181894449.459835.142190@c77g2000hse.googlegroups.com>
Content-Type: text/plain; charset="us-ascii"

This one is my favorite--I found something like this in a real program:

data interesting_diagnoses ; set all_diagnoses ; if dx_code = '300.4' or '400.3' or '900' or '111' ; run ;

That if statement is totally ineffectual--the text literals there get converted into numbers, which evaluate to a logical 'true', and so all of all_diagnoses winds up in interesting_diagnoses b/c of the (incorrectly expressed) logical condition there...

-Roy

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of ckxplus@yahoo.com Sent: Friday, June 15, 2007 1:01 AM To: SAS-L@LISTSERV.UGA.EDU Subject: mistakes in SAS that don't generate errors

I'm looking for ways to produce unexpected results in SAS that don't generate an error or warning message. Your syntax is fine, it works as SAS intended but not as you intended. Three examples:

* Inadvertantly respecify a user-defined format. (This does generate a note to the log that an existing format has been overwritten but that's easy to overlook).

* Using a "numbered range list" in a function, e.g. "sum(x1-x5)". This will calculate the sum of x1 minus x5, "sum(of x1-x5)" caculates the sum of x1 to x5.

* Forgetting that missing values are represented by minus infinity in comparisons.

Are there other nice examples of SAS syntax that looks like it does what you want it to at first glance or with insufficient coffee?

John Hendrickx


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