Date: Fri, 7 Feb 1997 10:23:14 -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: adding records to a dataset
Content-Type: text/plain; charset=us-ascii
jupiterbowl wrote:
>
> Is there a general strategy for adding records to reflect a missing value
> for SCORE in the missing months (Months 2,4-11 in the above case), besides
> editing the dataset the hard way?
>
Scot
There are several ways of doing this in a data step, one of which I've
included below (there may be better ways, but I don't have time to
examine all the possibilities right now) . I think it's pretty
self-explanatory, but if not email me and I'll fill in the details.
data new ;
set old;
by client ;
drop stormon storscor prevmon ;
prevmon = lag(month) ;
stormon = month ;
storscor = score ;
if first.client then prevmon = 0 ;
do month = (prevmon+1) to (stormon-1) ;
score = . ;
output ;
end;
score = storscor ;
month = stormon ;
output ;
if last.client & month ^= 12
then do month = (stormon+1) to 12 ;
score = . ;
output ;
end;
run;