## Percentage

Frequent Contributor
Posts: 82

# Percentage

Dear all,

I would like to calculate mutiple percentage by treatment and put it to one table . Is there any efficeint way for this ?

proc freq data = t ;

tables treatment *( d1  d2  d3  ................................ d100) ;

run;

With the following output table :

treatment       disease          count   percentage

1                   d1

d2

d3

.......

2

d1

d2

d3

..........

4

Thank you,

Ivy

Super User
Posts: 23,683

## Re: Percentage

Transpose your data and use proc freq.

Frequent Contributor
Posts: 82

## Re: Percentage

Thank you, I do not think that works .
Super User
Posts: 23,683

## Re: Percentage

Yes it does.

Why do you think it won't work? In fact, I think it was also suggested yesterday when you were looking for the maximum value.

Frequent Contributor
Posts: 82

## Re: Percentage

Transpose worked for yesterday data, but not today's freq. The following is the codes I used, I am not sure whether this is the way you suggested . Thank you.

proc transpose data = ads out= ads_t;
by index_year ;
var COPD Chronic_kidney_disease
Congestive_heart_failure Coronary_Heart_Disease Dementia Diabetes HIV_AIDS Hemiplegia
Infectious_hepatitis Peripheral_vascular_disease Rheumatoid_arthritis Stroke Ulcer_disease
Venous_thromboembolism Alcoholic_liver_disease ;
run;
Frequent Contributor
Posts: 82

## Re: Percentage

I would like to compare the different diseases percentage at different year. Thank you.
Super User
Posts: 23,683

## Re: Percentage

The word year doesn't appear in your initial post...

Please post sample data and sample expected output. You can make fake data for 5 or 10 d's rather than the full 100.

Frequent Contributor
Posts: 82

## Re: Percentage

[ Edited ]

Thank you, Reeza.

Sample data&colon;

treatment id d1 d2 d3
a 1 0 1 0
a 2 1 0 0
a 3 1 0 1
a 4 0 1 0
b 1 0 0 0
b 2 1 0 0
b 3 0 1 1
b 4 1 0 0

Output :

Treatment_a     Treatment_b     P-value
d1 (percent)

d2

d3

Super User
Posts: 23,683

## Re: Percentage

Because you've coded your data as binary, transpose and use proc means. Sum will provide count and mean will provide the percentage.

Frequent Contributor
Posts: 82

## Re: Percentage

Thank you, Reeza. I just realized I forgot to add P-value to the output. So maybe I use proc freq to loop the variables and combine the output together instead of doing the task in one step.
Super User
Posts: 23,683

## Re: Percentage

I have no idea what you want anymore...good luck.

Super User
Posts: 13,508

## Re: Percentage

What test will you be running to get a p-value?

Discussion stats
• 11 replies
• 412 views
• 0 likes
• 3 in conversation