Date: Wed, 14 Dec 2011 13:43:38 -0500
Reply-To: b miner <b_miner@LIVE.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: b miner <b_miner@LIVE.COM>
Subject: Add Missing Records to Table and Impute Values of Last Non
Missing.
Content-Type: text/plain; charset="iso-8859-1"
I have a dataset comprised of a group (G), a numeric value (x) and a sequential counter (within group) called s.
data test;
input G x s;
datalines;
1 1 1
1 2 2
1 . 3
2 . 1
2 1 2
3 1 1
3 2 2
3 . 1
3 . 1
4 1 1
4 2 2
4 3 3
4 4 4
;
run;
I want to first make sure each G has 4 records. So, G 1 would add 1 record with values . for x and 4 for s. G 2 would add two records (. and 3,4) etc.
Then, I want to scan the table and impute missing x values with the last non missing value for that group. So, for G 1 the missing value at s=1 will be a 2.
Is there an easy way to do this - using arrays?
|