全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
6804 4
2012-12-21
求助各位sas大神~~~假设我有一个数据,9000人的对照,100人的病例,我想运用logist做回归模型分析危险因素,条件logist回归,想以年龄进行匹配,比如年龄相差三岁的可以进行匹配。问题是:如何从9000人中随机选出这100个病例的匹配的对照。想做1:3的匹配。程序如何写?是不是要先分层呢?
资料类型:
y--应变量
age--年龄(匹配因素)
x1--影响因素1
x2--影响因素2
x3--影响因素3

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2012-12-21 13:25:25
复制代码
这个程序只是实现最简单的随机条件性选择。程序没有测试。在R编辑器里书写,在sas运行是改变#符号
京剧
This code is tested and works as expected. jngju



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-12-24 09:46:55
jingju11 发表于 2012-12-21 13:25
这个程序只是实现最简单的随机条件性选择。程序没有测试。在R编辑器里书写,在sas运行是改变#符号
京剧
T ...
There is a exist procedure, namely proc surveyselect that can deal with stratify sampling.

Here is an example,

data t1;
   do id=1 to 9100;
      x=ranuni(123);
          flag=0;
          if x<0.5 and cnt<=99 then do;
             flag=1;
                 output;
                 cnt+1;
          end;
          else output;
          
        end;
run;


proc freq data=t1;
table flag;
run;

proc sort data=t1;
by flag;
run;

proc surveyselect data=t1  n=(150 50)
                  seed=4321 out=Sample;
   strata flag;

run;

proc freq data=Sample;
table flag;
run;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-12-25 15:12:19
bobguy 发表于 2012-12-24 09:46
There is a exist procedure, namely proc surveyselect that can deal with stratify sampling.

Here ...
运行了下这个程序,倒是运行的出来,这个是成比例分层的程序,好像和我的还不太一样,我在想想呢。在此万分感谢。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-12-25 15:13:16
jingju11 发表于 2012-12-21 13:25
这个程序只是实现最简单的随机条件性选择。程序没有测试。在R编辑器里书写,在sas运行是改变#符号
京剧
T ...
这个程序没太看懂,可能是基础实在太差,无可挽救了,不过找了个同学和我一起研究呢。。弄好了在来回复吧。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群