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;
proc sql;
create table want as
select *,max(d) as d1
from have
group by Quarter;
quit;
2025 SAS Hackathon: There is still time!
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!