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 (March 2001, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 29 Mar 2001 15:39:30 -0500
Reply-To:   "Kerrison, Foster" <FKerrison@NT.DMA.STATE.MA.US>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Kerrison, Foster" <FKerrison@NT.DMA.STATE.MA.US>
Subject:   Re: first occurence, clarification
Content-Type:   text/plain

Then you just need to use descending on the class variable.

Try this:

data x ;

input id class count ;

cards; 5 50 1 5 10 2 5 10 3 ;

proc sort ; by id descending class descending count;

data y ; set x ; by id ; if last.id ; put _all_ ; run ;

id=5 class=10 count=2 FIRST.id=0 LAST.id=1 _ERROR_=0 _N_=3 NOTE: There were 3 observations read from the dataset WORK.X. NOTE: The data set WORK.Y has 1 observations and 3 variables. > -----Original Message----- > From: kin tang [SMTP:kintang1806@yahoo.com] > Sent: Thursday, March 29, 2001 3:14 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: first occurence, clarification > > Hello there, > > Just want to clarify on the dataset in the example. > 'CLASS' is not necessarily order. In other words, the > last value in 'CLASS' may not always the largest. > > It can also be: > > id class count > 5 50 1 > 5 10 2 > 5 10 3 > > In this case, record > > 5 10 2 > > needs to be output. > > Many thanks again. > > Ken > > ************************************************* > > Hello there, > > > I have a dataset of client records. I need to > determine the first occurance of the > last value for each client. The data looks like this: > > > id class count > > 1 20 1 > 1 20 2 > 1 10 3 > 1 10 4 > 2 20 1 > 2 30 2 > 3 50 1 > 3 50 2 > 3 50 3 > > > The output dataset will contain only the first > occurance of the last value, for example, > the last value of 'CLASS' is 30 for id1, therefore the > record > > 1 30 3 > > will be output; likewise, the last value of 'CLASS' > for id3 is 50, therefore, record line > > 3 50 1 > > should be output. > > > The outout dataset should look like this: > > 1 30 2 > 2 30 2 > 3 50 1 > > Any help will be greatly appreciated. > > Ken > > > > __________________________________________________ > Do You Yahoo!? > Get email at your own domain with Yahoo! Mail. > http://personal.mail.yahoo.com/?.refer=text


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