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 (November 2011, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 19 Nov 2011 01:27:13 +0000
Reply-To:     "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject:      Re: when to use OR vs AND with Multiple IF statements
In-Reply-To:  <587F57B26FAA8246A81D10D251EB8AB40296A81941@EXCH07.GHCMASTER.GHC.ORG>
Content-Type: text/plain; charset=utf-8

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > Pardee, Roy > Sent: Friday, November 18, 2011 4:36 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: when to use OR vs AND with Multiple IF statements > > Ah, thanks Tom--that clears it up for me. > > > Roy Pardee | DATA WRANGLER > Group Health Research Institute > > PHONE 360-447-8773 | 206-287-2078 > E-MAIL pardee.r@ghc.org > www.grouphealthresearch.org > -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > Tom Abernathy > Sent: Friday, November 18, 2011 10:31 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: when to use OR vs AND with Multiple IF statements > > Actually in practice with SAS character variables the : modifier works > well. > So if you have a variable DX that is $5 in length then it has '414 ' > in it as so DX =: '414.1' is false. > > data test; > length dx1 $5 dx2 $3 ; > dx1='414'; dx2='414'; > test1 = (dx1 =: '414.1'); > test2 = (dx2 =: '414.1'); > put (_all_) (=); > run; > > dx1=414 dx2=414 test1=0 test2=1 > > > You need to watch out when comparing to literals (or literals generated > by macro code for example). >

Well, I should have done a little testing before I posted what I did. :-) I am glad to know that it works that way. I now find the documentation could be a little clearer. In the above example, the length of dx1 using length(dx1) will be reported as 3, so I expected those three characters would be compared to the first three characters of the literal. So, when the documentation says the objects will be compared up to the length of the shorter of the two objects, the length being referred to is the physical storage space, not the value that would be reported by length(). I learn something everyday!

It is interesting (and to my mind, welcome) that trailing blanks are ignored in a standard EQ comparison, e.g. in the above example the comparison

dx1 EQ dx2

would be TRUE.

Dan

Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204


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