turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- ODS and Base Reporting
- /
- RBREAK

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-27-2009 03:22 AM

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...........

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...........

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-27-2009 12:41 PM

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.

To display the percentages with a % sign, use the PERCENT. format.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-28-2009 02:23 AM

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?

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?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-28-2009 08:01 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-28-2009 11:49 AM

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]

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

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

x y z total / row=float;

keylabel sum=' '

pctsum = ' '

all='Percent';

run;

ods html close;

[/pre]

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-30-2009 05:34 AM

Thanks a lot Cynthia..U have solved my problem

and thanks to u too tim

and thanks to u too tim