BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,
I want to create an AE table (pref in TABULATE) that shows the # with each AE and (here's the part I'm having problems with...) %'s of all subjects - even those who have any AE.
Any help?
Thanks
Mike
5 REPLIES 5
Cynthia_sas
SAS Super FREQ
Hi:
Are you using PCTN, PCTSUM or any of the other percent-related statistics???
http://support.sas.com/kb/22/983.html

If you are, then you would need a Picture format to add a percent sign to the created number. Even those this example was for a SAS/Graph procedure, the picture format is what you would use:
http://support.sas.com/kb/24/877.html
[pre]
/* Create a format for the values of PERCENT. The PCTFMT. */
/* format rounds the percentage to no decimal places and */
/* adds a percent sign to the value. */

proc format;
picture pctfmt (round) 0-high='000%';
run;
[/pre]

Then, inside your TABULATE code, you'd have this (or have the format in the TABLE statement):
[pre]

/* The FORMAT statement applies the PCTFMT. */
/* to the values of PERCENT. */
format percent pctfmt.;
[/pre]

If you are asking how to calculate a percent with your own denominator, you'd have to look in the doc or papers for examples. You specify your own denominator within < and > operators on the TABLE statement. There are some examples in these papers:
http://www2.sas.com/proceedings/sugi30/127-30.pdf
http://www2.sas.com/proceedings/sugi30/258-30.pdf

cynthia
deleted_user
Not applicable
Thanks for the response,
The picture format is a good idea - I will use that (when I get the %'s working). I think specifying a denominator would work, but the var I would want as a denominator isn't (directly) included in the summary table. Here's an example of the type of data I have...

ID TEXT
1 text1
1 text2
1 text3
2 text1
3
4 text2

So the table should look like this...

Total N 4 (100%)
Text1 2 (50%)
Text2 2 (50%)
Text3 1 (25%)

When I use PCTN I get %'s based on total number of TextX instead of total ID.
Do you know how I could achieve this
Thanks
Mike
LawrenceHW
Quartz | Level 8
Mike,

The only way (that I can think of) is to calculate the percentages in a data step prior to reporting. I really don't like proc tabulate and would rather use proc report but that's a personal preference.

The n (%) variable can be created as a character type (i.e. 2 (50%)) using whatever method you want and then just use proc report to print out the results.
deleted_user
Not applicable
a denominator can be an analysis variable.
You need an analysis variable that provides the required denominator at the crossing level where you report. The analysis var used as denominator does not need to appear anywhere else in the table (just in the data).

If you show a sample of data with the denominator value required, we'll be more help.

good luck

PeterC
deleted_user
Not applicable
I agree with LawrenceHD where he gets his data organized prior to reporting and when it really looks the way he wants it he use Proc Report to display it. That's the way I do to.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

Discussion stats
  • 5 replies
  • 1502 views
  • 0 likes
  • 3 in conversation