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 (August 2002, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 28 Aug 2002 16:03:18 -0400
Reply-To:     Howard_Schreier@ITA.DOC.GOV
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Howard_Schreier@ITA.DOC.GOV
Subject:      Re: LOCF (Last Observation Carried Forward) with Caveat

Here's a one-step (but two-pass) tested solution.

data filled; drop eos_score last_visit locf; do until (last.patient); set sample(in=preview) sample ; by patient; if preview then do; if visit='End of Study' then eos_score = score; else if score ne '' then last_visit = visit; end; else do; if score='' then do; if visit<last_visit then score = locf; else score = eos_score; end; locf = score; output; end; end; run;

I added PATIENT as an ID variable.

The first pass through each patient's data just picks up the end-of-study value and the point of discontinuation. The second pass does the filling as specified.

On Wed, 28 Aug 2002 09:50:02 -0400, David Friedman <harrypotterdhf@EARTHLINK.NET> wrote:

>I am working with pharmaceutical data. I want to use LOCF to carry an >observation forward. However if a patient discontinues early I want to take >the last observation (End of Study) and impute that value from the point >that the patient discontinued to the End of the Study. Do any of you have >any SAS Code for this scenario as I am struggling with it. By the way I >have SAS Version 6.12 installed here. Below is sample input and expected >output: > >Sample Input dataset: > >Visit Score > >1 Poor >2 . >3 Good >4 . >5 . >End of Study Fair > > >Expected Output: > >Visit Score > >1 Poor >2 Poor >3 Good >4 Fair >5 Fair >End of Study Fair


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