I have a variable D. Now I want to create another variable say D1 which takes the maximum value of D by each quarter.Just as below. Just unsure how to go about it in SAS
data have;
input D Quarter;
datalines;
0 1
0 1
1 1
0 2
0 2
0 2
0 3
2 3
1 3
;
data want;
do until (last.Quarter);
set have;
by Quarter;
if D > D1 then D1=D;
end;
do until (last.Quarter);
set have;
by Quarter;
output;
end;
run;