Hi SAS expert, I have a sequential data set, each id have two observations, a sample dataset looks like below: data have;
input id month var1;
datalines;
1 6 2
1 14 1
2 9 3
2 14 1
;
run; First I would like to calculate the change of var1, var1_change, defined as the last obs minus the first obs, and calculate the change per month,var1_change_per_month, defined as the change/interval, the dataset I got looks like this: data cal;
input id month var1 var1_change interval var1_change_per_month;
datalines;
1 6 2 . . .
1 14 1 -1 8 -0.125
2 9 3 . . .
2 14 1 -2 5 -0.4
;
run; Now I would like to fill in the gaps between two observations with the calculated var1_change_per_month, the dataset i want would look like this: data want;
input id month var1_change_per_month;
datalines;
1 6 -0.125
1 7 -0.125
1 8 -0.125
1 9 -0.125
1 10 -0.125
1 11 -0.125
1 12 -0.125
1 13 -0.125
1 14 -0.125
2 9 -0.4
2 10 -0.4
2 11 -0.4
2 12 -0.4
2 13 -0.4
2 14 -0.4
;
run; Any ideas would be appreciated. Thanks!
... View more