Y*H 发帖数: 1582 | 1 I have two datasets,one finds if a person has the type of disease(a,b,c,d,e)
. One has the corresponding risk factor for each disease.
How can I use SAS to calculate the total risk? I'm thinking about making two
arrays and multiply them together but do not know the code...
Any help is appreciated. Thanks!
A B C D E Sex
Person 1 0 1 0 1 0 M
Person 2 1 0 1 0 1 M
Person 3 0 0 0 0 0 F
Person 4 0 1 0 0 0 M
Pers |
j*****e 发帖数: 182 | 2 merge the two dataset by person. |
A*********u 发帖数: 8976 | 3 by gender
merge the two dataset by person.
【在 j*****e 的大作中提到】 : merge the two dataset by person.
|
Y*H 发帖数: 1582 | 4 谢谢楼上2位!
请问用merge的话,程序哪里会计算total risk呢?merge不是只能把2个dataset合成
一个么?这样的话是不是要人工输入rate?实际的dataset有200多种disease rate,是不是不管怎样都要人工输入一遍disease rate?麻烦不怕,主要怕输错数。
我SAS很菜。。。请高手指教,谢谢! |
A*********u 发帖数: 8976 | 5 merge可以同时merge多个
最多多少个记不清了
大不了分两到三步应该就行了
total risk你不是都有公式了吗
merge以后不就是一行code吗
谢谢楼上2位!
请问用merge的话,程序哪里会计算total risk呢?merge不是只能把2个dataset合成
一个么?这样的话是不是要人工输入rate?实际的dataset有200多种disease rate,是
不是不管怎样都要人工输入一遍disease rate?麻烦不怕,主要怕输错数。
我SAS很菜。。。请高手指教,谢谢!
【在 Y*H 的大作中提到】 : 谢谢楼上2位! : 请问用merge的话,程序哪里会计算total risk呢?merge不是只能把2个dataset合成 : 一个么?这样的话是不是要人工输入rate?实际的dataset有200多种disease rate,是不是不管怎样都要人工输入一遍disease rate?麻烦不怕,主要怕输错数。 : 我SAS很菜。。。请高手指教,谢谢!
|
Y*H 发帖数: 1582 | |
a*******a 发帖数: 1336 | |
Y*H 发帖数: 1582 | 8 wo kan kan
【在 a*******a 的大作中提到】 : consider using SAS IML
|
g**r 发帖数: 425 | 9 There are many ways to do this, but one way is simply reformat the disease;
the most straightforward way is operate in the first data:
if A=1 and sex='M' then DA=0.5;
if A=1 and sex='F' then DA=1;
etc.
Sounds very tedious, but you can use a simple data step on your second data
to do this; something like the following and then copy it from your log.
data tt;
set test;
array d(2) a b;
array cn(2) aa bb;
do i=1 to 2;
*put "if" vname(d(i)) "= 1 then " vname(n(i)) '=' d ;
c= |
l****h 发帖数: 272 | 10 Use Proc SQL, assuming dataset1 is named t1 and dataset2 t2.
PROC SQL;
CREATE TABLE RiskTable AS
SELECT T1.*, (T1.A*T2*A + T1.B*T2*B + T1.C*T2*C + T1.D*T2*D + T1.E*T2*E + T1
.F*T2*F) AS riskscore from T1, T2 WHERE T1.gender = T2.gender;
run;
the result is stored in the new dataset "RiskTable" |