Check the MERGE skill proposed by Me and Arthur.T :
https://support.sas.com/resources/papers/proceedings15/2785-2015.pdf
data have;
input office $ dept $ year seq $ code $ me_amt me_pct;
datalines;
LA IT 2024 1 101 10000 0
LA IT 2024 1 102 66 12
MI FIN 2024 1 101 333 1
MI FIN 2024 1 102 98.7 12.3
;
run;
proc sql noprint;
select distinct catt('have(where=(code="',code,'" )
rename=(me_amt=me_amt_',code,' me_pct=me_pct_',code,'))') into :merge separated by ' '
from have;
quit;
data want;
merge &merge.;
by office dept year;
drop code;
run;
... View more