The SAS Output Delivery System and reporting techniques

RBREAK

Reply
N/A
Posts: 0

RBREAK

HI all,
This is my data set..........

STAGE X Y Z TOTAL
A 1 2 2 5
B 3 6 9 18
C 1 2 5 8
TOTAL 5 10 16 31

By using rbreak in proc report we can get this 'TOTAL' row means we can summarize the data but instead of total i want percentage of data values with respect to total and with % sign along with it..Like..........

TOTAL 16.1% 32.2% 51.6% 100%

SO IS IT POSSIBLE?

Thanks for ur help...........
Super Contributor
Posts: 394

Re: RBREAK

Posted in reply to deleted_user
Check out PROC REPORT's COMPUTE statement. Here's the doc: http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a000068725.htm. Also you can use the "Search Forum" link to find the answers given for very similar questions on this forum. Here's one such example: http://support.sas.com/forums/thread.jspa?messageID=18961䨑.

To display the percentages with a % sign, use the PERCENT. format.
N/A
Posts: 0

Re: RBREAK

Hi buddy,

thanks for ur help,

the examples which u have mentioned by that we can get the percentage in column but not in a row..I want to have the calculated percentage at the end of the dataset in a row...wat i hav done i hav preapred a new data set consisting of only one row to calculate the percentage..then i hav converted botth the datasets column into character format..after that using '||' i have attached % sign with the percenatge data set....and then i have appended both the datasets..but this is a long procedure..isnt there any simpler way?
Super Contributor
Posts: 394

Re: RBREAK

Posted in reply to deleted_user
Use a COMPUTED column to compute the percentage. Use the FORMAT= option on the DEFINE statement of the column to associate the PERCENT. format with the column.
SAS Super FREQ
Posts: 8,861

Re: RBREAK

Hi:
As much as I love PROC REPORT, I'm tempted to give this one to PROC TABULATE to produce the report. The ability to calculate percentages is very straightforward with TABULATE and usually produces the percentage you want either with a keyword percentage (ROWPCTSUM, COLPCTSUM, etc) or with a demoninator definition <denom> specified in the TABLE statement. PROC REPORT will do the job, but it does require some extra coding above and beyond basic PROC REPORT coding.

The only thing that TAB does that takes some getting used to is that it does an automatic multiply by 100 for percentages, which means that you cannot use the SAS pre-defined percent format. But with a PICTURE format, you can fix that easily and get a % into your cells. For example, given the data shown above, the TABULATE code would be as shown below. The PROC FORMAT step is defining a PICTURE format for use in the TABLE statement *f=pct. crossing, otherwise, the comma8 format will be used for all the other cells.

cynthia
[pre]
data getpct;
infile datalines;
input stage $ x y z total;
return;
datalines;
A 1 2 2 5
B 3 6 9 18
C 1 2 5 8
;
run;

proc format;
picture pct low-high='009.9%';
run;

ods listing close;
ods html file='c:\temp\getpct.html' style=sasweb;
proc tabulate data=getpct f=comma8.;
class stage;
var x y z total;
table stage all*pctsum*f=pct.,
x y z total / row=float;
keylabel sum=' '
pctsum = ' '
all='Percent';
run;
ods html close;
[/pre]
N/A
Posts: 0

Re: RBREAK

Posted in reply to deleted_user
Thanks a lot Cynthia..U have solved my problem
and thanks to u too tim
Ask a Question
Discussion stats
  • 5 replies
  • 165 views
  • 0 likes
  • 3 in conversation