DATA Step, Macro, Functions and more

how to use transpose to generate new tables and calculate relative risk with proc freq

Reply
Super Contributor
Posts: 345

how to use transpose to generate new tables and calculate relative risk with proc freq

data have;
input group $ subgp $ a b c;
datalines;
s amy 	71130	12739	11243
s brivy	14144	2548	2214
s vor	81841	6538	5820
s dce	68065	3775	3288
ase am 79199 20314 17987
bse bf 55981 5286 4578
g as2 703236 16685 14776
g bs5 6337 6747 5918
g co5 8607 2186 1881
;
data want;
set have;
d=a-c;
run;
proc transpose data=want out=notc prefix=group;
by group;
id subgp;
var d;
run;
proc print data=notc;
run;

I have several groups. Each group has two or over two outcomes. I want to use proc freq to calculate relative risk.

My orginal data has two variables listed above. I need to have a new variable, d, that is, d=a-c

then, i put d and c into the following code (b is not needed). I wonder whether there is a way, whether I can use transpose to make it more efficiently. and always, use first one of the subgroup (subgrp) as a reference, rr=1

 

data question;
input subgrp $ Response $ Count;
datalines;
brivy Yes 2240
brivy No 11930

amy Yes 11243
amy No  2214

 

**************************

proc freq data=question order=data;
weight Count;
tables subgrp*Response / relrisk;
run;

Super User
Posts: 19,822

Re: how to use transpose to generate new tables and calculate relative risk with proc freq

Proc freq won't calculate relative risk with more than 2 groups. As indicated, I'm not sure your actually using the relative risk measure correctly, because you don't have a case/control situation. If you have an observational study you should be using odds ratio instead.

Super Contributor
Posts: 345

Re: how to use transpose to generate new tables and calculate relative risk with proc freq

I need to have each 2X2 tables, with the first one as the reference.

For each new table I generate, it is a kind of case control

Ask a Question
Discussion stats
  • 2 replies
  • 149 views
  • 0 likes
  • 2 in conversation