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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1363 views
  • 0 likes
  • 3 in conversation