|
On Tue, 29 Apr 2008 09:00:22 -0400, wcw2 <wcw2@CDC.GOV> wrote:
>Subtracting Values in a Single Column
>
>Hello fun-seekers...I want to *groan* subtract the AUC values of DRUG B -
>DRUG A and DRUG C - DRUG A and so on (for x # of drugs) BY PATIENT, to
>produce the output on the right (B-A and C-A), in order to do a signed rank
>test on the differences. I was thinking about sorting by patient, then
>drug, and then using the DIF function. Would this work? Or, if there’s an
>easier way (other than rearranging the whole dataset), I’d so much
>appreciate any help......many thanks!
>
>
>Patient Drug AUC B-A C-A
>1 A 10 30 90
>2 A 20 40 100
>3 A 30 50 80
>1 B 40
>2 B 60 -> ->
>3 B 80
>1 C 100
>2 C 120
>3 C 150
Here's a way which does not require hard-coding the names of the non-A drugs:
proc sql;
create table diffs as
select a.patient
, cats(other.drug,'-A') as pair
, other.auc - a.auc as diff
from (select * from auc where drug EQ 'A') as a
join
(select * from auc where drug NE 'A') as other
on a.patient = other.patient
order by patient, pair;
quit;
|