Date: Thu, 6 May 2004 17:08:07 -0400
Reply-To: Venky Chakravarthy <venky.chakravarthy@PFIZER.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Venky Chakravarthy <venky.chakravarthy@PFIZER.COM>
Subject: Re: In Operator with numbers
This has been documented in a SAS Note. See
http://support.sas.com/techsup/unotes/V6/2/2178.html
Venky
On Wed, 5 May 2004 16:41:16 -0400, Dianne Rhodes <RHODESD1@WESTAT.COM>
wrote:
>We have some legacy code that uses the in(inlist) to compute a flag
>variable. I have never seen this notation used this way, and the result is
>not what was expected. Actually, I would have thought you'd get a syntax
>error, since SAS seems to be interpreting the values as separated, even
>though there is no comma separating them.
>
>3 data test ;
>4 do _i = -50 to 50 ;
>5 surg=_i ;
>6 output ;
>7 end;
>8 drop _i;
>9 run;
>
>NOTE: The data set WORK.TEST has 101 observations and 1 variables.
>NOTE: DATA statement used:
> real time 0.23 seconds
> cpu time 0.02 seconds
>
>
>10
>11 data test1 ;
>12 set test ;
>13 if surg in(1-5,12-14, 30-34, 44-46, 48-50) then surgflag=1 ;
>14 else surgflag=0 ;
>15 run;
>
>NOTE: There were 101 observations read from the data set WORK.TEST.
>NOTE: The data set WORK.TEST1 has 101 observations and 2 variables.
>NOTE: DATA statement used:
> real time 0.00 seconds
> cpu time 0.00 seconds
>
>
>16 title1 "IN(1-5,12-14,30-34,44-46,48-50)" ;
>17
>18 proc print data=test1 noobs;
>19 where surgflag=1 ;
>20 run;
>
>NOTE: There were 10 observations read from the data set WORK.TEST1.
> WHERE surgflag=1;
>
>Output:
> IN(1-5,12-14,30-34,44-46,48-50) 15:35 Wednesday,
May
>5, 2004 1
>
> surg
surgflag
>
> -50 1
> -46 1
> -34 1
> -14 1
> -5 1
> 1 1
> 12 1
> 30 1
> 44 1
> 48 1
>
>Anyone know of documentation of this gotcha? Is it something new in V8.2?
>
>Dianne Louise Rhodes
>Sr. Systems Analyst
>Westat
|