BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
DanielP91
Fluorite | Level 6

Hello 

 

In need of some help regarding proc tabulate and how to format my output a certain way. 

 

My current code:

ods _all_ close;


ods excel file="E:\Users\Daniel Paredes\ALLPCLEVELS.xlsx";

proc tabulate data=final style=minimal format=comma6.;
class User District / order=data s=[font_weight=bold];
var Email--Progressing;

table User*District all ='Average'*f=6.2,
Email--Progressing*mean=' '/s=[font_weight=light font_size=6] nocellmerge;
run;

 

ods excel close;
ods listing;

My current codes output image below

DanielP91_0-1678168161676.png

 

What I am trying to achieve and am having issues coding this is below:

DanielP91_2-1678168201105.png

I would like my new tabulate report to have a heading called 'PC Actions Taken' above the columns Email to Other with a sum of those columns called 'Total Action Taken'. And a heading called 'PC Level of Contact' above columns High to Progressing with a sum of those columns called 'Total Levels of Contact'. 

 

Your help and suggestions would be greatly appreciated. 

 

I've also attached the spreadsheet with the example sheets. 

.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software or organization policy. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.

 

It helps to post code into a text box opened with the </> icon above the message window to preserve formatting and to set the code apart from question text.

Place the statistic request before the variable names and override the statistic label

proc tabulate data=final style=minimal format=comma6.;
    class User District / order=data s=[font_weight=bold];
    var Email--Progressing;

    table User*District all ='Average'*f=6.2,
    mean='Total Action Taken'/s=[font_weight=light font_size=6]* ( Email--Other) 
    mean='PC Level of Contact'/s=[font_weight=light font_size=6]* ( High--Processing) 
   ;
run;

 

 

View solution in original post

2 REPLIES 2
ballardw
Super User

Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software or organization policy. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.

 

It helps to post code into a text box opened with the </> icon above the message window to preserve formatting and to set the code apart from question text.

Place the statistic request before the variable names and override the statistic label

proc tabulate data=final style=minimal format=comma6.;
    class User District / order=data s=[font_weight=bold];
    var Email--Progressing;

    table User*District all ='Average'*f=6.2,
    mean='Total Action Taken'/s=[font_weight=light font_size=6]* ( Email--Other) 
    mean='PC Level of Contact'/s=[font_weight=light font_size=6]* ( High--Processing) 
   ;
run;

 

 

DanielP91
Fluorite | Level 6

Thanks ballarddw your suggested code has worked. Appreciate that. 

 

Also, will make a note the information you provide for future reference. A little new to this community and still finding my way around 🙂

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
  • 588 views
  • 0 likes
  • 2 in conversation