BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10


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?

2 REPLIES 2
Phil_NZ
Barite | Level 11

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;

 

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
andreas_lds
Jade | Level 19

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;

 

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1046 views
  • 0 likes
  • 3 in conversation