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 (February 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 25 Feb 2008 02:56:40 -0800
Reply-To:     Sylar <rifazrazeek@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Sylar <rifazrazeek@GMAIL.COM>
Organization: http://groups.google.com
Subject:      Re: Calculating Days Since Last Visit
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=ISO-8859-1

Hi David,

Yes, LAG function would be an easy way to do it.

See some code below.

Hope it helps. Rif

======================================= data dset1; input patient date date9.; format date date9.; datalines; 1 01JAN08 1 08JAN08 1 14JAN08 2 02JAN08 2 09JAN08 2 15JAN08 ; RUN;

proc sort data=dset1; by patient; run;

data dset2; set dset1; by patient; last_visit=lag(date); if first.patient then last_visit=.;

days_since_last_visit=date-last_visit; format last_visit date9.; run; ==============================================

On Feb 25, 9:06 am, harrypotter...@EARTHLINK.NET (David Friedman) wrote: > For a given patient visit I want to calculate the days since last visit. I > have several visit records per patient. I want to get output something > like this: > > Patient # Visit Date Days since last visit > 1 1/1/2000 . > 1/8/2000 7 > 2/1/2000 30 > > What is the best way to do this? Lag function?


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