Date: Mon, 27 Jan 2003 16:43:59 -0800
Reply-To: shiling zhang <shiling99@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: shiling zhang <shiling99@YAHOO.COM>
Organization: http://groups.google.com/
Subject: Re: missing() in 'where' statement
Content-Type: text/plain; charset=ISO-8859-1
Move on to 8.2.
The following log is from 8.2.
189 data t1;
190 do i =1 to 5;
191 output;
192 end;
193 i=.;output;
194 run;
NOTE: The data set WORK.T1 has 6 observations and 1 variables.
NOTE: DATA statement used:
real time 0.05 seconds
195
196 data t2;
197 set t1;
198 where missing(i)=0;
199 run;
NOTE: There were 5 observations read from the data set WORK.T1.
WHERE MISSING(i)=0;
NOTE: The data set WORK.T2 has 5 observations and 1 variables.
NOTE: DATA statement used:
real time 0.00 seconds
200
201 data t2;
202 set t1(where=( missing(i)=0));
203 run;
NOTE: There were 5 observations read from the data set WORK.T1.
WHERE MISSING(i)=0;
NOTE: The data set WORK.T2 has 5 observations and 1 variables.
NOTE: DATA statement used:
real time 0.05 seconds
204
205 proc sql;
206 create table t2 as
207 select *
208 from t1
209 where missing(i)=0;
NOTE: Table WORK.T2 created, with 5 rows and 1 columns.
210 quit;
NOTE: PROCEDURE SQL used:
real time 0.00 seconds
peetie_wheatstraw@lycos.com (Peetie Wheatstraw) wrote in message news:<OMCGOEPPHDEMDBAA@mailcity.com>...
> Lucid minds,
>
> The missing() function returns 0 if the argument is
> non-missing and 1 if the argument is missing.
>
> In this 8.1 log, missing() works fine in the first
> data step and fails in the subsequent steps.
>
> 323 data a;
> 324 input id mo amt;
> 325 ** adding this to check result of missing function: **;
> 326 m=missing(amt);
> 327 put _all_;
> 328 cards;
>
> id=1 mo=1 amt=22 m=0 _ERROR_=0 _N_=1
> id=1 mo=2 amt=33 m=0 _ERROR_=0 _N_=2
> id=1 mo=3 amt=44 m=0 _ERROR_=0 _N_=3
> id=2 mo=1 amt=99 m=0 _ERROR_=0 _N_=4
> id=2 mo=2 amt=88 m=0 _ERROR_=0 _N_=5
> id=2 mo=3 amt=. m=1 _ERROR_=0 _N_=6
> NOTE: The data set WORK.A has 6 observations and 4 variables.
> NOTE: DATA statement used:
> real time 0.02 seconds
> cpu time 0.02 seconds
>
>
> 335 ;
> 336 run;
> 337
> 338 data b;
> 339 set a(where=(missing(amt)=0));
> 340 by id mo;
> 341 if last.id;
> 342 put _all_;
> 343 run;
>
> NOTE: There were 0 observations read from the data set WORK.A.
> WHERE MISSING(amt)=0;
> NOTE: The data set WORK.B has 0 observations and 4 variables.
> NOTE: DATA statement used:
> real time 0.02 seconds
> cpu time 0.02 seconds
>
>
> 344
> 345 proc sql;
> 346 select *
> 347 from xx
> 348 where missing(amt)=0;
> NOTE: No rows were selected.
> 349 quit;
> NOTE: PROCEDURE SQL used:
> real time 0.01 seconds
> cpu time 0.01 seconds
>
> If I run:
>
> data b;
> set a;
> by id mo;
> if missing(amt)=0;
> if last.id;
> put _all_;
> run;
>
> it works OK, so I have a situation in which missing()
> is dysfunctional in a 'where' statement. Howcum? Is
> this documented?
>
> Moreover, if some SAS functions are dysfunctional in
> 'where' statements, how can we determine which work/
> don't-work? Just by intuition? Is there a list in the
> doc?
>
> Or am I just 'missing' something silly here (no pun
> intended, but, what the hull)... :-)
>
> Peetie
>
>
>
> _____________________________________________________________
> Get 25MB, POP3, Spam Filtering with LYCOS MAIL PLUS for $19.95/year.
> http://login.mail.lycos.com/brandPage.shtml?pageId=plus&ref=lmtplus