data have;
input Mgr $ Exception $ CNT ;
datalines;
Smith Transfer 1
Smith Transfer 1
Smith Cancel 1
Brown Reinstate 1
Brown Terminate 1
Saunders Transfer 1
Saunders Cancel 1
;
run;
proc sql;
create table have2 as
select Mgr,Exception,sum(cnt) as tot_cnt
from have
group by Mgr,Exception
;quit;
proc transpose data=have2 out=want let;
id Exception;
var tot_cnt;
by Mgr;
run;
1. Is it possible to rename tot_cnt as My_Count
2. If I had multiple var could I rename each var as desired?
You can, just using the option rename.
proc transpose data=have2 out=want (rename=(_NAME_=My_Count)) let;
id Exception;
var tot_cnt;
by Mgr;
run;
Your dataset "want" looks like a report. Do you really need a dataset?
If not, try proc tabulate:
proc tabulate data=have format=5.;
class Mgr Exception;
var cnt;
table Mgr= ' ', Exception*cnt= ' ' / box= 'Mgr';
keylabel sum= ' ';
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.