LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (March 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 21 Mar 2006 12:01:34 -0800
Reply-To:     "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Subject:      Re: Comparison in IF clause
Comments: To: Gerhard Hellriegel <ghellrieg@T-ONLINE.DE>
Content-Type: text/plain; charset="US-ASCII"

Hi Gerhard - interesting stuff - I'd be tempted to express it as "mod(i,32)<16" as in:

data a; do i=0 to 255; x= mod(i,32)<16; put i= x=; end; run;

But the bit mask _is_ quicker. Try this:

data a; do i=0 to 1e7; x=(i='...0....'b); end; run;

data a; do i=0 to 1e7; x= mod(I,32)<16; end; run;

hth

Paul Choate DDS Data Extraction (916) 654-2160

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > Gerhard Hellriegel > Sent: Tuesday, March 21, 2006 10:11 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: Comparison in IF clause > > That makes a binary compare. > If you have a decimal 2, the binary representation in the length of 8 bit > is > > '00000010'b > > means: > > 0*2**7 + 0*2**6 + .... + 1*2**1 + 0*2**0 > > In that way you can represent numbers from 0 to 255 > > The comparison you mention now means: > > all numbers which have the 5th bit (from the right side) as "0" are equal. > E.g. '000000000', but also '111101111'b > > by the way: you have 9 digits, that's unusual. Maybe you mean 8, but 9 or > more is also ok. > > That is a very strong feature. Note the results of that little program: > > data a; > do i=0 to 255; > x=(i='...0....'b); > put i= x=; > end; > run; > > You see, that you can also get the same result with comparing decimals, > but > which are selected in: > > if i="...0...."b; > > thats a very elegant way to write: > > if i in (0,1,2,3,4,5,6,7,8,9....,15,32,33,34,...); or something like > > if 0<=i<=15 or 32<=i<=47 or ...; > > > > > > > > On Tue, 21 Mar 2006 05:56:17 -0800, ssb <mail_ssb@YAHOO.COM> wrote: > > >Hello, > > > >Am new to SAS programming and this may be too elementary for some > >people. Suppose, MY_VARIABLE is a field of input record layout and its > >size is 1 byte. > > > >What does the following comparison statement do exactly...? Is the > >right side of the comparison-equation in form of packed / zoned / > >binary data...? > > > >IF MY_VARIABLE = '....0....' B > > > >Thanks for your help.


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