|
Dear All:
Here is my data set.
VarA VarB
A 11
A 12
A 16
A 10.5
B 4
A 6
A 8
A 9
B 11.5
B 12.5
B 3
A 12
A 13
I want to construct to variables VarC and VarD which are flags of the last
observations of the groups of VarA
VarA VarB VarC VarD
A 11 0 0
A 12 0 0
A 16 0 0
A 10.5 1 0
B 4 0 1
A 6 0 0
A 8 0 0
A 9 1 0
B 11.5 0 0
B 12.5 0 0
B 3 0 1
A 12 0 0
A 13 1 0
I wrote the following:
data have; set have;
if VarA = A and last.VarA then do VarC = 1 ; end;
else do VarC = 0; end;
if VarA = B and last.VarB then then do VarD = 1 ; end;
else do VarD = 0; end;
run;
What mistake am I making?
Randy
|