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

## two decimals in percentages in proc tabulate

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
Super User

## Re: two decimals in percentages in proc tabulate

@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.

3 REPLIES 3
Super User

## Re: two decimals in percentages in proc tabulate

@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.

SAS Super FREQ

## Re: two decimals in percentages in proc tabulate

Hello,

Rowpctn*format=comma18.2

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

Koen

Pyrite | Level 9

## Re: two decimals in percentages in proc tabulate

thank you @ballardw
Discussion stats
• 3 replies
• 1363 views
• 0 likes
• 3 in conversation