BookmarkSubscribeRSS Feed
RHL
Calcite | Level 5 RHL
Calcite | Level 5
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.
4 REPLIES 4
Cynthia_sas
SAS Super FREQ
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]
RHL
Calcite | Level 5 RHL
Calcite | Level 5
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.
Cynthia_sas
SAS Super FREQ
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
RHL
Calcite | Level 5 RHL
Calcite | Level 5
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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1364 views
  • 0 likes
  • 2 in conversation