Date: Mon, 11 Apr 2005 22:23:52 +1000
Reply-To: Scott Bass <usenet739_yahoo_com_au@ALFREDO.CC.UGA.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Scott Bass <usenet739_yahoo_com_au@ALFREDO.CC.UGA.EDU>
Subject: Re: select observation
Hi,
I don't think a variable list can be used in a where statement but, since it
can be used in a data step, one approach would be to use a data step view:
* crude test case ;
data one;
length q1-q3 8;
input q2 q3;
q1=_n_;
cards;
9 .
. 1
. 9
2 .
9 .
. 3
. 9
4 .
;
run;
data two / view=two;
set one;
array vars{*} q1-q3;
do i=1 to dim(vars);
if vars{i}=9 then do;
output;
continue;
end;
end;
* drop i; /* uncomment after debugging */
run;
proc print data=two;
run;
"Jerry" <greenmt@gmail.com> wrote in message
news:1113197632.439144.61350@l41g2000cwc.googlegroups.com...
> Hi,
>
> I have 15 consecutive numeric variables,(q1, q2, .... q15). My
> objective is to list all observations for which any of the 15 varibles
> contains a numeric value "9". Below is the code I wrote, using PROC
> PRINT w/ WHERE statement.
>
> proc print data=test;
> where q1=9 or q2=9 or q3=9 or q4=9 or q5=9 or q6=9 or q7=9 or q8=9 or
> q9=9 or q10=9 or q11=9 or q12=9 or q13=9 or q14=9 or q15=9;
> run;
>
> My clumsy code works fine, but I wonder if there's a better way to
> achieve my objective.
>
> Thanks.
> Jerry
>
|