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 2011, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 13 May 2011 23:30:31 -0500
Reply-To:     Joe Matise <snoopy369@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Matise <snoopy369@GMAIL.COM>
Subject:      Re: How to keep the most recent date ?
Comments: To: Irin later <irinfigvam@yahoo.com>
In-Reply-To:  <202712.47221.qm@web39401.mail.mud.yahoo.com>
Content-Type: text/plain; charset=ISO-8859-1

use PROC SORT by memberid fromedate (use the numeric one please!), then in a data step use the LAST operator:

data want; set have; by memberid frmdt; if last.memberid; format frmdt DATE9.; run;

That keeps the last memberid in date order. Format statement makes it look pretty.

-Joe

On Fri, May 13, 2011 at 10:49 PM, Irin later <irinfigvam@yahoo.com> wrote:

> I am trying to get a recent date of medical test for each patient. > > memberid fromedate > 12345 2009-01-05 00:00:00.000 > 12345 2009-10-06 00:00:00.000 > 12345 2009-02-07 00:00:00.000 > > 33445 2009-03-04 00:00:00.000 > 33445 2009-10-06 00:00:00.000 > 33445 2009-12-01 00:00:00.000 > 22222 2009-10-06 00:00:00.000 > > I need to keep patient with the most recent date: > > 12345 2009-10-06 00:00:00.000 > > 33445 2009-10-06 00:00:00.000 > > 22222 2009-10-06 00:00:00.000 > > The proc content showed the character date: > Alphabetic List of Variables and Attributes > > # Variable Type Len Format Informat Label > 4 fromdate Char 255 $255. $255. fromdate > > > which I converted into numeric: > # Variable Type Len Format Informat Label > > 4 frmDt Num 8 > > Now frmDt field looks like SAS date....something nor readable. > > My questions are the followings: > > 1.HOW to keep the most recent date record? > 2.How to make it look readable? > > Thank you in advance, > > Irin >


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