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;
Ready to join fellow brilliant minds for the SAS Hackathon?
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.