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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.