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 (December 2010, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 3 Dec 2010 15:37:10 -0500
Reply-To:     joe zhou <g75wez1@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         joe zhou <g75wez1@GMAIL.COM>
Subject:      Re: Replacing missing values by the previous non-missing value
Comments: To: toby dunn <tobydunn@hotmail.com>
In-Reply-To:  <BLU152-w4309E45FBBF8E9F977FD8FDE280@phx.gbl>
Content-Type: text/plain; charset=ISO-8859-1

Toby, Thanks a lot. Your code works like magic!

On Fri, Dec 3, 2010 at 3:18 PM, toby dunn <tobydunn@hotmail.com> wrote: > Untested but should work: > > > Data Need ; > Set Have ; > Retain _Q1 _Q1 ; > > If Not Missing( Q1 ) Then _Q1 = Q1 ; > If Not Missing( Q2 ) Then _Q2 = Q2 ; > > Q1 = Coalesce( Q1 , _Q1 ) ; > Q2 = Coalesce( Q2 , _Q2 ) ; > > Run ; > > > > Toby Dunn > > > "I'm a hell bent 100% Texan til I die" > > "Don't touch my Willie, I don't know you that well" > > > > >> Date: Fri, 3 Dec 2010 15:05:34 -0500 >> From: g75wez1@GMAIL.COM >> Subject: Replacing missing values by the previous non-missing value >> To: SAS-L@LISTSERV.UGA.EDU >> >> Hello all, >> >> I need your SAS expertise in terms of replace the missing >> values by using their previous non-missing values within a group. >> >> Have a data like: >> >> data have; >> input q1 q2 q3 q4; >> cards; >> 1 1 1 10 >> . . 2 11 >> . 2 1 200 >> . . 2 201 >> 2 1 1 100 >> . . 2 101 >> . 2 1 2000 >> . . 2 2001 >> ; >> >> Wanted data: >> 1 1 1 10 >> 1 1 2 11 >> 1 2 1 200 >> 1 2 2 201 >> 2 1 1 100 >> 2 1 2 101 >> 2 2 1 2000 >> 2 2 2 2001 >> >> Thank you very much for your helps. >> >> >> Joe >


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