Date: Mon, 22 May 2006 13:39:34 -0400
Reply-To: "Rickards, Clinton (GE Consumer Finance)"
<clinton.rickards@GE.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Rickards, Clinton (GE Consumer Finance)"
<clinton.rickards@GE.COM>
Subject: Re: Finding observation # associated with a value
In-Reply-To: A<1148318021.492091.48740@u72g2000cwu.googlegroups.com>
Content-Type: text/plain; charset="iso-8859-1"
Paul,
To answer your specific question, this should do:
data _null_;
set pauls_data;
if x="usable" then
do;
put "first usable row is " _n_;
call symput("usable_row",put(_n_, 9.));
stop;
end;
run;
But a better solution might be to use a where data set option:
data usable;
set pauls_data (where=(x="usable"));
--- more sas code ---
run;
Your approach has the advantage of launching directly to the row you want but is advantageous only if your data is static. the Where option cuts down on some of the IO.
HTH,
Clint
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of Paul
Sent: Monday, May 22, 2006 1:14 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Finding observation # associated with a value
I have a large data set that looks something like this:
X Y
garbage 2
garbage 1
garbage 3
... ...
usable 4
usable 16
usable 31
... ...
I'd like to know which observation is the first one with X="usable" so
that I don't have to waste time reading the observations with
X="garbage". For example, if the first 10,000 lines are garbage, I can
save time by using the subset mydata (firstobs=10001).
Any suggestions most appreciated.
Best wishes,
Paul
|