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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Registration is open
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss. Register now and lock in 2025 pricing—just $495!