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 (January 2004, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 8 Jan 2004 15:19:46 GMT
Reply-To:     julierog@ix.netcom.com
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Roger Lustig <trovato@VERIZON.NET>
Subject:      Re: Working with dates
Content-Type: text/plain; charset=us-ascii; format=flowed

Dear Jen: Try this.

data new; flag=0; *** Reset flag for new person; do until (last.person_id); *** Loop through one person's data; set old; *** Get a record; by person_id; *** allow LAST.<var> processing; if flag=0 then output; *** If prev. record didn't have the key date, *** then we can output this one.; if end='30oct2003'd then flag=1; *** But only the 1st one with key date; end; *** End of loop for one person's data; run; *** Go to top of DATA step to reset flag;

OK?

Roger

Jennifer R Popovic wrote: > I have a dataset of begin and end dates of an event, multiple events per > person. I've pasted an example of one person's data below (sorted by > begin date). What I need to do for each person is to make the first obs > with an END date of 10/30/2003 the last observation for that person. So > for the person below, the fifth obs would be the last b/c I'd want to > delete the last three obs. > I know there must be an easy way to do this, but for some reason can't > seem to make it work. Any suggestions? > > obs begin end > 1 04/24/2001 04/28/2001 > 2 09/09/2001 12/19/2001 > 3 02/18/2002 03/29/2002 > 4 04/23/2002 04/27/2002 > 5 10/10/2002 10/30/2003 > 6 01/08/2003 01/09/2003 > 7 02/25/2003 10/30/2003 > 8 07/14/2003 10/30/2003 > > Thanks, > Jen


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