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;

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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