|
楼主

楼主 |
发表于 2012-7-7 16:36:34
|
只看该作者
求助:问题出在哪里?
大家好,我是一名医生,最近写文章要用到propensity score matching. 我在网上查到一篇文献,
<!-- m --><a class="postlink" href="http://www2.sas.com/proceedings/sugi29/165-29.pdf">http://www2.sas.com/proceedings/sugi29/165-29.pdf</a><!-- m --> 该文献可以进行1:n的配对。但我以前对SAS基本没接触,用的最多的是SPSS.硬着头皮下载了SAS软件,照猫画虎总算完成了propensity score的计算。但是在运行文献给出的macro的时候总是报错。有没有哪位大侠帮我看看到底是什么问题,不胜感谢。
出错的地方在这:
[color=#0000BF:2pwured9]NOTE: Line generated by the invoked macro "MATCH".[/color:2pwured9]
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;
[color=#BF0000:2pwured9] ----
180[/color:2pwured9]
1 ! oldi = 1; end; DO i = start to n; set &lib..Scontrol point = i nobs = n
[color=#BF0000:2pwured9]ERROR 180-322: Statement is not valid or it is used out of proper order.[/color:2pwured9]
[color=#0000BF:2pwured9]NOTE: The SAS System stopped processing this step because of errors.[/color:2pwured9]
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;
所有的语句都在我提供的链接的文献里能找到。
谢谢大家了。 |
|