[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: Table calculations
From:       "Dunn, Toby" <Toby.Dunn () TEA ! STATE ! TX ! US>
Date:       2004-11-30 20:56:25
[Download RAW message or body]

Or a data step solution might look like the following:

data test2 (drop = y_:);
set test (in = first)
    test (in = second);
by Center;
retain y_1st y_2nd;

if first then do;
  if x = 0 then y_1st = y;
  if x = 1 then y_2nd = y;
end;

if second then do;
  if y_2nd then d = y_1st / y_2nd;
  else          d = 0;
  output;
end;
run;

HTH
Toby Dunn

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of K
Fernandes
Sent: Tuesday, November 30, 2004 2:36 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Table calculations


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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic