LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 22 May 2006 13:39:34 -0400
Reply-To:     "Rickards, Clinton (GE Consumer Finance)"
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Rickards, Clinton (GE Consumer Finance)"
Subject:      Re: Finding observation # associated with a value
Comments: To: Paul <paulvonhippel@YAHOO.COM>
In-Reply-To:  A<>
Content-Type: text/plain; charset="iso-8859-1"


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.


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

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