Contributor
Posts: 44

# finding the percent age in total column

 year x y percent 2010 10 5 50% 2011 23 6 26% 2012 25 2 8% 2013 20 4 20% 2014 17 8 47% total 95 25 26%

The above report gets total and %'s in total column .

(i want 26% in totals)

plz help me

SAS Super FREQ
Posts: 825

## Re: finding the percent age in total column

You can use Proc REPORT to get the output you need. You can make use of the computed column functionality:

<

data have;
infile cards dlm=",";

input
year x y
;
cards;
2010,10,5
2011,23,6
2012,25,2
2013,20,4
2014,17,8
;

proc report data=have nowindows;

column year x y myPct;
define year / display;

define x / analysis;

define y / analysis;

define myPct / computed format=percent9.0;

compute myPct;
myPct = y.sum / x.sum;

endcomp;

rbreak after / summarize;
run;

/body>

Super User
Posts: 9,599

## Re: finding the percent age in total column

Hi,

proc sql;

create table WANT as

select     *

from       HAVE

union all

select     "Total" as YEAR,

count(X) as X,

count(Y) as Y,

round((CALCULATED Y / CALCULATED X) * 100,1.) as PERCENT

from        HAVE;

quit;

Super User
Posts: 13,583

## Re: finding the percent age in total column

And a Tabulate solution

proc tabulate data=have;

class year;

var x y;

table year='' all='Total',

x *sum=''*f=best4.     y=''*(sum='y'*f=best4. pctsum<x>='%'*f=best4.)

/box='Year' ;

run;

Discussion stats
• 3 replies
• 239 views
• 0 likes
• 4 in conversation