## Percentages in Summary Tables

Occasional Contributor
Posts: 9

# Percentages in Summary Tables

Hi,

I'm trying to duplicate PROC TABULATE code in EG using the Summary Tables task but have a problem with calculating percentages. How would you create the equivalent of PCTN< > (calculating the percentage based on a class variable, not necessarily the whole row or column)?

Thanks in advance for any help.
SAS Super FREQ
Posts: 9,424

## Re: Percentages in Summary Tables

Hi:
I do not know whether there's a way to specify a custom denominator in the EG wizard or task. You may have to generate a simple N and PCTN table and then modify the generated code to use a custom denominator with the < and > angle brackets.

See the code example below. The custom denominator (in the second table definition) tells Proc Tabulate to calculate the PCTN across all the products within each region. So, you would see in this instance, that the PCTN for all the products for each region will add up to 100%.

cynthia
[pre]
ods html file='custom_denom.html' style=sasweb;

proc tabulate data=sashelp.shoes;
where region in ('Asia', 'Canada', 'Pacific');
title 'Compare These Tables';

class region product;

table region*(product all) all,
n pctn
/box='1) Regular N and PctN';

table region*(product all) all,
n pctn<product all>
/box='2) Custom Denominator';

run;

ods html close;
[/pre]
Occasional Contributor
Posts: 9

## Re: Percentages in Summary Tables

Hi Cynthia,

I've tried to do what you suggested, but I don't think EG allows me to insert code at the point where I need to put the angle brackets.
SAS Super FREQ
Posts: 9,424

## Re: Percentages in Summary Tables

Hi:
You may be right, that there's no way to insert the code in the EG task.

The thing you may have to do is to highlight the task in EG and then Export the code. Save the code file to a location where you can find it again. Then open the code file in a code node and edit the code.

At this point, you will need to test the code node to be sure that it produces the output you want. Once you know that you've edited the code and are getting the results you want, you probably don't want/need the original Summary Tables Task anymore and can use the code node instead to generate your report.

cynthia
Occasional Contributor
Posts: 9

## Re: Percentages in Summary Tables

I guess this means that it really can't be done just by point and click, or drag and drop. I could just as easily type the code into a code node.
Discussion stats
• 4 replies
• 295 views
• 0 likes
• 2 in conversation