BookmarkSubscribeRSS Feed
ss171
Calcite | Level 5

Hi , I am new with proc tabulate . I have a dataset below 

CRM_E1COUNTPERCENT
01.03E+0898.4695
19530550.91539
21954850.187759
31362250.130841
41074460.1032
5967040.092882
61045590.100427

I need to format the below with some custom format color and total at the end. Resultant output is attached. Can this be done by proc tabulate or proc report Capture.PNG

2 REPLIES 2
PaigeMiller
Diamond | Level 26

You need to assign the desired formats to variables count and percent by using the FORMAT statement in PROC TABULATE. Here is an example: https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=proc&docsetTarget=p13k5zc...

--
Paige Miller
ballardw
Super User

This is one way maybe:

data have;
input CRM_E1 :$5.	COUNT	PERCENT;
datalines;
0	1.03E+08	98.4695
1	953055	0.91539
2	195485	0.187759
3	136225	0.130841
4	107446	0.1032
5	96704	0.092882
6	104559	0.100427
;

proc report data=have;
   columns  CRM_E1	COUNT	PERCENT;
   define crm_e1/"E1 value" style(header)=[background=cyan]
                group ;
   ;
   define COUNT/"Count" style(header)=[background=cyan];
   define PERCENT/"Percent" style(header)=[background=cyan];
   rbreak after / summarize style=[background=cyan fontweight=bold];
   compute after;
      crm_e1='Total';
   endcomp;

run;

If your crm_e1 variable is not character you will have some issues getting a character "Total" in a column expecting numeric values.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 924 views
  • 2 likes
  • 3 in conversation