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 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, 23 Feb 2009 13:08:17 -0800
Reply-To:     "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject:      Re: Time-to-event calculation for large dataset
In-Reply-To:  <15a355120902231151r44e4e6aft3a90302533697091@mail.gmail.com>
Content-Type: text/plain; charset=iso-8859-1

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On > Behalf Of Rieza Soelaeman > Sent: Monday, February 23, 2009 11:52 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Time-to-event calculation for large dataset > > Dear SAS-Lers, > This is a fairly simple operation, I'm sure, but I can't > figure it out in > SAS language. I'm trying to do an analysis of how long it takes us to > collect necessary data through follow-ups. An illustrative example: > Person Date document entered Doc Number Does document > have all necessary > information? Info on this person is complete in DB Miles > 5/1/2008 1 N N > Miles 8/8/2008 2 N N Miles 12/1/2008 3 Y Y Miles 1/1/2009 4 Y Y Miles > 1/4/2009 5 N Y Otis 2/4/2007 1 N N Otis 2/4/2008 2 N N John > 3/6/2006 1 Y Y > John 3/24/2006 2 N Y John 2/27/2007 3 Y Y John 5/9/2007 4 N Y > Louis 5/1/2007 > 1 Y Y Ornette 7/27/2006 1 N N Ornette 7/31/2006 2 Y Y Ornette > 12/27/2006 3 N > Y Thelonious 8/27/2006 1 N N Thelonious 9/9/2008 2 Y Y > data dbinfo; > input person $ 1-10 @12 date_doc_ent docnum doc_has_info $ > info_complt $; > > datalines ; > Miles 05012008 1 N N > Miles 08082008 2 N N > Miles 12012008 3 Y U > Miles 01012009 4 Y U > Miles 01042009 5 N U > Otis 02042007 1 N N > Otis 02042008 2 N N > John 03062006 1 Y Y > John 03242006 2 N Y > John 02272007 3 Y Y > John 05092007 4 N Y > Louis 05012007 1 Y Y > Ornette 07272006 1 N N > Ornette 07312006 2 Y Y > Ornette 12272006 3 N Y > Thelonious 08272006 1 N N > Thelonious 09092008 2 Y Y > ; > run; > > I have programming to calculate the # of days, I just want to > know how I can > pick the first document that has all the necessary info (if the first > entered document does not contain that info). So for > example, I want to > pick Document 3 for Miles, Document 2 for Ornette, and Document 2 for > Thelonious. I'm not worried about John and Louis, because > the info I have > on them are both complete on the first try. For them, I > would probably do if > first.person and does doc have all necessary info="Y" then infolag= > 0;because there were 0 days b/w entry of first document and my > obtaining that > last piece of info that would make my db entry on that person > complete. > > I was thinking then of using if first.person and does doc have all > necessary info = "N" then do; but like I said before, I'm > not sure how to > pull something that is not the last entry for that person > (last.person) > As always, many thanks in advance! > > -- > Rieza H Soelaeman >

You didn't specify what you wanted for output, bu this should get you started. I used the notsorted option on the by statement because you persons are not in sorted order. The program assumes the data for each person are grouped together and within person are in date order (as in you sample data).

data want(keep=person first_date complete_date complete); set dbinfo; by person notsorted; if first.person then do; first_date = date_doc_ent; complete_date = .; complete = 0; retain first_date complete_date complete ; end; if not complete and info_complt = 'Y' then do; complete_date = date_doc_ent; complete = 1; end; if last.person then do; info_lag = complete_date - first_date; output; end; run;

Hope this is helpful,

Dan

Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204


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