Contributor
Posts: 60

# Calculating percentage

Hi
Can somebody help me with this.
Data:
Name operations next actiondate
Bob A sent 11.Jan.2011
John A sent 11.Jan.2011
Bob A sent 11.Jan.2011
John A sent 11.Jan.2011
John A sent 11.Jan.2011
Bob A sent 12.Jan.2011
John A sent 12.Jan.2011
Bob A sent 12.Jan.2011
John A sent 12.Jan.2011
Bob B fail 11.Jan.2011
John B fail 11.Jan.2011
Bob B pass 11.Jan.2011
John B wait 11.Jan.2011
John B pass 11.Jan.2011
Bob B fail 12.Jan.2011
John B fail 12.Jan.2011
Bob B pass 12.Jan.2011
John B pass 12.Jan.2011

Sas statement:
proc tabulate data=SVBZ01A0.user_end_debug;
keylabel n = ' ';
class name operations next actiondate;
table name='' * operations='' * next='', actiondate='' all='Total'

/ misstext='0';
run;

Result is table:
First column name; second is split into two rows operations A and B; Third: A is always sent and B is split into fail/pass/wait; all by date

What I want is to make new column percentage for fail/pass/wait of SENT for every day:

Bob sent(A) 2 pc 11.Jan.2011 one is fail one is pass(B). In new colum should be fail 50% and pass 50%

John sent(A) 3 pc 11.Jan.2011 one is fail,one is pass and one is wait(B) In new colum should be fail 33,3%, pass 33,3% and wait 33,3%

Not applicable
Posts: 0

## Re: Calculating percentage

Hello,

From your details I understand that Sum of B (fail, pass, wait) equal A (sent).
if my assumption is correct then a little rearrangement of your tabulate may be more appropriate:

[pre]
Data x;
input Name \$ operations \$ next \$ actiondate date11.;
format actiondate date7.;
datalines;
Bob A sent 11.Jan.2011
John A sent 11.Jan.2011
Bob A sent 11.Jan.2011
John A sent 11.Jan.2011
John A sent 11.Jan.2011
Bob A sent 12.Jan.2011
John A sent 12.Jan.2011
Bob A sent 12.Jan.2011
John A sent 12.Jan.2011
Bob B fail 11.Jan.2011
John B fail 11.Jan.2011
Bob B pass 11.Jan.2011
John B wait 11.Jan.2011
John B pass 11.Jan.2011
Bob B fail 12.Jan.2011
John B fail 12.Jan.2011
Bob B pass 12.Jan.2011
John B pass 12.Jan.2011
;
proc tabulate data=x format=8.1;
keylabel n = 'Total';

class name next operations actiondate;

table name=''* actiondate='',
(next=''*rowpctn='Percent') all='Sent'*format=5.*{style={color=red fontweight=bold}}

/ misstext='0' box={label='My Table represents...' Style={backgroundcolor=yellow}} ;

where next ne 'sent';
run;
[/pre]

Marius

Contributor
Posts: 60

## Re: Calculating percentage

Hello Marius
Thank you very much working like a charm.
Bob
Contributor
Posts: 60

## Re: Calculating percentage

Hi Marius
Is it possible to change place of actiondate and next? I mean to have on left side name next and percent and on top actiondate.
Not applicable
Posts: 0

## Re: Calculating percentage

hello Bob,

here is a soltuion with denominator:

[pre]
proc tabulate data=x format=8.1 ;
keylabel n = 'Total';

class name next operations actiondate;

table name=''* (next=''*pctn='Percent' all='Sent'*format=5.*{style={color=red fontweight=bold}}),
actiondate=''

/ misstext='0' box={label='My Table represents...' Style={backgroundcolor=yellow}} ;

where next ne 'sent';
run;
[/pre]

HTH,
Marius
Contributor
Posts: 60