BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dustychair
Pyrite | Level 9

Hi all,

I have a question. I am using the below code to format the total. By using this I am getting percentages with no decimals. However, I want the N counts to have no decimals but the percentages have two decimals. How can I modify it?

 

Thank you,

 

proc tabulate data=alt501_main out=gender_grade;
class gender grade /missing;
table grade (all= 'Total'* format=comma16.) ,
gender *(N*format=comma16. Rowpctn)(all= 'Total'* format=comma16.);
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@dustychair wrote:

Hi all,

I have a question. I am using the below code to format the total. By using this I am getting percentages with no decimals. However, I want the N counts to have no decimals but the percentages have two decimals. How can I modify it?

 

Thank you,

 

proc tabulate data=alt501_main out=gender_grade;
class gender grade /missing;
table grade (all= 'Total'* format=comma16.) ,
gender *(N*format=comma16. Rowpctn)(all= 'Total'* format=comma16.);
run;

 


gender *(N*format=comma16. Rowpctn*f=6.2)(all= 'Total'* format=comma16.);

 

Should work. If you want different behavior for values like 100 or 0 you could create a custom format.

View solution in original post

3 REPLIES 3
ballardw
Super User

@dustychair wrote:

Hi all,

I have a question. I am using the below code to format the total. By using this I am getting percentages with no decimals. However, I want the N counts to have no decimals but the percentages have two decimals. How can I modify it?

 

Thank you,

 

proc tabulate data=alt501_main out=gender_grade;
class gender grade /missing;
table grade (all= 'Total'* format=comma16.) ,
gender *(N*format=comma16. Rowpctn)(all= 'Total'* format=comma16.);
run;

 


gender *(N*format=comma16. Rowpctn*f=6.2)(all= 'Total'* format=comma16.);

 

Should work. If you want different behavior for values like 100 or 0 you could create a custom format.

sbxkoenk
SAS Super FREQ

Hello,

 

Rowpctn*format=comma18.2

I guess your decimals will be .00 as otherwise 2 decimals would have been displayed.

 

Koen

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 2092 views
  • 0 likes
  • 3 in conversation