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 (March 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 17 Mar 2009 14:51:46 -0400
Reply-To:     Akshaya <akshaya.nathilvar@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Akshaya <akshaya.nathilvar@GMAIL.COM>
Subject:      Re: how to substitute a missing value with previous record?
Comments: To: Ya Huang <ya.huang@amylin.com>
In-Reply-To:  <200903171839.n2HAmaGR026054@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1

I posted DOW solution(adopted from previous Data _null_'s post) earlier. That will fill the consecutive missing spots from previous non-missing value. Data want; do until(eof); set have end=eof; locf=ifn(missing(score),locf,score); output; end; Run;

On Tue, Mar 17, 2009 at 2:39 PM, Ya Huang <ya.huang@amylin.com> wrote:

> This won't work if you have more than one consecutive missing: > > data xx; > input x $ value; > cards; > 3/17/2009 2 > 3/18/2009 3 > 3/19/2009 7 > 3/20/2009 . > 3/21/2009 . > 3/22/2009 4 > 3/23/2009 9 > ; > > data better; > drop previous; > previous = value ; > set xx ; > value1 = coalesce( value, previous); > run; > > proc print; > run; > > value x value1 > > 2 3/17/200 2 > 3 3/18/200 3 > 7 3/19/200 7 > . 3/20/200 7 > . 3/21/200 . > 4 3/22/200 4 > 9 3/23/200 9 > > the missing in value1 is expected to be 7. > > On Tue, 17 Mar 2009 13:53:34 -0400, Peter Crawford > <peter.crawford@BLUEYONDER.CO.UK> wrote: > > >i like the smallest. > >data better ; > > drop previous; > > previous = value ; > > set original ; > > value= coalesce( value, previous); > >run; > > > > > >On Tue, 17 Mar 2009 08:20:56 -0700, Yi Zhang <zhangyiosu@GMAIL.COM> > wrote: > > > >>hi guys, > >>I has a time series data with some missing values. I want to > >>substitute the missing value with the value in the last time. For > >>example, I have > >>3/17/2009 2 > >>3/18/2009 3 > >>3/19/2009 7 > >>3/20/2009 3 > >>3/21/2009 missing > >>3/22/2009 4 > >>3/23/2009 9 > >> > >>I want to have > >>3/17/2009 2 > >>3/18/2009 3 > >>3/19/2009 7 > >>3/20/2009 3 > >>3/21/2009 3 > >>3/22/2009 4 > >>3/23/2009 9 > >> > >>Any idea how to do this in a DATE STEP? >

-- AkshayA!


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