Date: Tue, 30 Nov 2004 15:48:47 0500
ReplyTo: Ya Huang <ya.huang@AMYLIN.COM>
Sender: "SAS(r) Discussion" <SASL@LISTSERV.UGA.EDU>
From: Ya Huang <ya.huang@AMYLIN.COM>
Subject: Re: Table calculations
A very good candidate for proc sql:
data xx;
input Center x m y;
cards;
1 0 2 0
2 0 4 3
2 1 2 2
3 0 5 3
3 1 3 1
;
proc sql;
select *,
max(case when x=0 then y else . end)/max(case when x=1 then y else . end)
as d
from xx
group by center
order by center,x
;

Center x m y d

1 0 2 0 .
2 0 4 3 1.5
2 1 2 2 1.5
3 0 5 3 3
3 1 3 1 3
Kind regards,
Ya Huang
On Tue, 30 Nov 2004 15:36:29 0500, K Fernandes <kafernan@UWATERLOO.CA>
wrote:
>Hello,
>
>I have a table of count data that is formatted like this:
>
>Center x m y
>1 0 2 0
>2 0 4 3
>2 1 2 2
>3 0 5 3
>3 1 3 1
>
>...etc.
>
>where x is a treatment, y is the outcome, and m is the total number of
>people who received treatment x.
>
>I would like to add another column to this table, d, that is calculated
>based on the values of y. I'm not sure what the most efficient way of
>doing this is, since there is only one value of d per given Center
>value. For example, for a given center, say d=(y from row where x=0)/(y
>from row where x=1). Could someone give me some help as to how I might
>code this?
>
>Another thing which makes this more complicated is that because m
>happens to equal 0 for Center=1, x=1, there is no corresponding row for
>x=1 in the table above.
>
>I hope that made sense.
>Thank you for your help,
>Kim
