Name County Total Type Year Med Bel
site1 A 34 1 2000 2 3
site2 C 12 2 2000 2 2
site3 C 44 1 2000 2 2
site4 A 25 1 2002 3 2
site5 B 23 2 2002 0 2
site6 C 13 1 2002 1 3
Output:
Type1 Type2
Total Med PctMed Bel PctBel Total Med PctMed Bel Total Med PctMed Bel PctBel
2000 90 6 6.6 7 7.7 78 4 5.1 etc...
2002 61 4 6.5 7 11.4 48 4 8.3 etc...
I tried this but it doesn't work. Any help you can give will be much appreciated!
ods html file = 'C:\MyDocuments\procreport_pct.html';
proc report data=want nowd;
title 'Report';
COLUMN year total med bel, type;
DEFINE year / group;
DEFINE total / sum;
DEFINE med / sum;
DEFINE med_pct / COMPUTED FORMAT = percent8.2;
DEFINE bel / sum;
DEFINE bel_pct / COMPUTED FORMAT = percent8.2;
rbreak after / summarize;
run;
hi,
try with proc tabualate...but not sure if it works...
You should change the table cloulmns...
PROC TABULATE DATA=HAVE;
VAR TOTAL MED BEL ;
TABLE YEAR , (TYPE) *(TOTAL*(N PCTN) MED*PCTN);
CLASS YEAR TYPE ;
RUN;
Regards
ALLU
Thanks!
Hi,
I'm confused. I don't see how the PROC REPORT code that you show can produce the output that you posted. For one thing, you only cross or nest BEL with TYPE, but in your output, it looks like you have med med_pct bel and bel_pct under each type, so I would have expected a COLUMN statement like:
COLUMN year total type,( med med_pct bel bel_pct);
But, maybe you also have TOTAL under each TYPE. It's hard to say.
And then, you DEFINE both med_pct and bel_pct as COMPUTED usage, but you don't show the COMPUTE blocks. So I'm not sure how you're getting numbers for med_pct or bel_pct.
Did you run code to get the output you posted? Or is the output you posted a mock-up of what you hope to get?
To do this kind of report, you will have to investigate using Absolute column numbers for calculating percents in the COMPUTE block, you will have to figure out what you want in the column statement first, because the order of the variables in the column statement will impact the absolute column numbers.
Or, you might want to try this with TABULATE, as previously suggested.
cynthia
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.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.