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 2011, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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?


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