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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.