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 (October 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 26 Oct 2009 12:47:13 -0400
Reply-To:     Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject:      Re: how to get first obs from datasets sorted by two variables?

what do you want more? After

if first.id;

you HAVE the first obs of each ID-group...

Gerhard

On Mon, 26 Oct 2009 12:17:15 -0400, Jeff <zhujp98@GMAIL.COM> wrote:

>I have a dataset d1: >id x y z w >1 1 3 4 6 >1 4 8 9 0 >2 22 44 44 8 >2 23 34 45 8 >2 12 3 4 7 >; > > >which is sorted by two variables id and x in ascending order. >I want to get the first obs after sorting, >which is: >id x y z w >1 1 3 4 6 >2 12 3 4 7 > >I tried >proc sort data=d1; >by id x; >run; > >data sub_d1; >set d1; >if first.id=1 and ... /* what should i do here*/ > >Thanks, >Jeff


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