全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1680 5
2012-07-07
大家好,我是一名医生,最近写文章要用到propensity score matching. 我在网上查到一篇文献,
http://www2.sas.com/proceedings/sugi29/165-29.pdf 该文献可以进行1:n的配对。但我以前对SAS基本没接触,用的最多的是SPSS.硬着头皮下载了SAS软件,照猫画虎总算完成了propensity score的计算。但是在运行文献给出的macro的时候总是报错。有没有哪位大侠帮我看看到底是什么问题,不胜感谢。
出错的地方在这:
NOTE: Line generated by the invoked macro "MATCH".
1      data &lib..&matched. (drop=Cmatch randnum aprob cprob start oldi curctrl matched);  set
1  ! &lib..SCase ; curob + 1; SUGI 29 Posters 8 matchto = curob; if curob = 1 then do; start = 1;
                              ----
                              180

1  ! oldi = 1; end;  DO i = start to n; set &lib..Scontrol point = i nobs = n
ERROR 180-322: Statement is not valid or it is used out of proper order.

NOTE: The SAS System stopped processing this step because of errors.
log上好像总说macro "MATCH"有错误,但我又不知道错在哪儿。
我下面把文献中macro "MATCH"那段也贴出来:
/* ********************* */
/* Macro to Perform the Match */
/* ********************* */
%MACRO MATCH (MATCHED,DIGITS);
data &lib..&matched. (drop=Cmatch randnum aprob cprob start oldi curctrl matched);
/* select the cases data set */
set &lib..SCase ;
curob + 1;
SUGI 29 Posters
8
matchto = curob;
if curob = 1 then do;
start = 1;
oldi = 1;
end;
/* select the controls data set */
DO i = start to n;
set &lib..Scontrol point = i nobs = n;
if i gt n then goto startovr;
if _Error_ = 1 then abort;
curctrl = i;
/* output control if match found */
if aprob = cprob then
do;
Cmatch = 1;
output &lib..&matched.;
matched = curctrl;
goto found;
end;
/* exit do loop if out of potential matches */
else if cprob gt aprob then
goto nextcase;
startovr: if i gt n then
goto nextcase;
END; /* end of DO LOOP */
/* If no match was found, put pointer back*/
nextcase:
if Cmatch=0 then start = oldi;
/* If a match was found, output case and increment pointer */
found:
if Cmatch = 1 then do;
oldi = matched + 1;
start = matched + 1;
set &lib..SCase point = curob;
output &lib..&matched.;
end;
retain oldi start;
if _Error_=1 then _Error_=0;
run;
/* get files of unmatched cases and controls */
proc sort data=&lib..scase out=sumcase;
by &SiteN. &PatientN.;
run;
proc sort data=&lib..scontrol out=sumcontrol;
by &SiteN. &PatientN.;
run;
proc sort data=&lib..&matched. out=smatched (keep=&SiteN. &PatientN. matchto);
by &SiteN. &PatientN.;
run;
data tcases (drop=matchto);
merge sumcase(in=a) smatched;
by &SiteN. &PatientN.;
if a and matchto = . ;
cmatch = 0;
aprob =Round(prob,&digits.);
run;
data tctrl (drop=matchto);
merge sumcontrol(in=a) smatched;
SUGI 29 Posters
9
by &SiteN. &PatientN.;
if a and matchto = . ;
cmatch = 0;
cprob = Round(prob,&digits.);
run;
%SORTCC
%MEND MATCH;
所有的语句都在我提供的链接的文献里能找到。
谢谢大家了。
二维码

扫码加我 拉你入群

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

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

全部回复
2012-7-7 17:01:22
谢谢大家了,经过逐字逐句的对比,我发现我错在哪儿了。
谢谢。
二维码

扫码加我 拉你入群

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

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

2012-7-7 21:30:38

SUGI 29 Posters
8
SUGI 29 Posters
9

This is garbage and is not part of SAS language. You may accidentally paste it in.
二维码

扫码加我 拉你入群

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

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

2012-9-2 17:47:08
you are right.
二维码

扫码加我 拉你入群

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

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

2012-9-2 23:06:13
胡江堂不是说吗?当学医的和学统计的合作的话,那就是最纯粹的技术交流。支持LZ。
Ps:Lz有问题可以发Email给胡,他是搞生物统计的,SAS很牛,你可以联系他。http://www.jiangtanghu.com/
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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