Date: Fri, 3 Dec 2010 20:18:10 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: Replacing missing values by the previous non-missing value
In-Reply-To: <201012032005.oB3JRfrf002446@malibu.cc.uga.edu>
Content-Type: text/plain; charset="iso-8859-1"
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
|