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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 2502 views
  • 0 likes
  • 3 in conversation