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 1997, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 13 Feb 1997 10:24:02 -0800
Reply-To:     gxx18300@ggr.co.uk, BWRogers@MSN.COM
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Bruce Rogers <gxx18300@GGR.CO.UK>
Organization: Medical IR, Glaxo Wellcome
Subject:      Re: filling missing values with lagged values
Comments: To: Jennifer Soller <jennifer.soller@sf.frb.org>
Content-Type: text/plain; charset=us-ascii

Jennifer Soller wrote: > > Hello to all. > Here's a little problem I was given by a friend > who is pulling her hair out. > Checked out past posts on dejanews to no avail. > Hope someone can work their usual magic. > > I have the following dataset: > > OBS X > 1 1 > 2 . > 3 . > 4 2 > 5 2 > 6 2 > 7 . > 8 3 > 9 3 > 10 . > 11 . > 12 . > 13 . > 14 4 > 15 . > > What I want is the following: > > OBS X > 1 1 > 2 1 > 3 1 > 4 2 > 5 2 > 6 2 > 7 2 > 8 3 > 9 3 > 10 3 > 11 3 > 12 3 > 13 3 > 14 4 > 15 4 > > I want the missing values replaced by the previous > non-missing value. I thought that: <snip> > I'm thinking about > arrays and have read Ron Cody's array tutorials, > but nothing is jumping out at me. > > Any advice? > Much thanks.

Jennifer,

There is a _very_ simple way to achieve this, as follows:

DATA ONE (drop=tempvar); SET MYDATA; retain tempvar ; IF X = . THEN x = tempvar ; else tempvar = x ; run;

I hope this is clear and self-explanatory - if you don't understand it then I suggest you read up on the RETAIN statement.

Bruce


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