BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

Using SAS 9.4

 

I am attempting to run the %CIF macro running the following code:

 

options mprint;

%CIF (data= check,out= CIF, time= TT_censor_date, status= binary_amputation, group=binary_gender, event=1);

 

TT_censor_date is a numeric variable

binary_amputation is 1/0 numeric variable (0 indicates no amp)

binary_gender 1/0 numeric variable (0 indicates male)

 

Below is an example of the variables I am using from my data set:

data have;
input id tt_censor_date binary_amputation binary_gender;
datalines;
1 8 1 0
2 50 0 1
3 100 1 1
4 200 0 0
5 679 1 0
;
run;

 

when I run the macro I get the following error in the log:

1 The SAS System 08:06 Thursday, October 1, 2020

1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='CR_100120';
4 %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5 %LET _CLIENTPROJECTPATH='';
6 %LET _CLIENTPROJECTPATHHOST='';
7 %LET _CLIENTPROJECTNAME='';
8 %LET _SASPROGRAMFILE='G:\Outcomes Research\Foot and Ankle Projects\Davis\FA079 and FA088 - TMA Amputation - Hodges
8 ! Davis\TMA to BKA or AKA\data\September 2020\CR_100120.sas';
9 %LET _SASPROGRAMFILEHOST='OCRSPC028';
10
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=PNG;
13 GOPTIONS XPIXELS=0 YPIXELS=0;
14 FILENAME EGSR TEMP;
15 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16 STYLE=HTMLBlue
17 STYLESHEET=(URL="file:///C:/Program%20Files%20(x86)/SASHome/x86/SASEnterpriseGuide/7.1/Styles/HTMLBlue.css")
18 NOGTITLE
19 NOGFOOTNOTE
20 GPATH=&sasworklocation
21 ENCODING=UTF8
22 options(rolap="on")
23 ;
24
25 GOPTIONS ACCESSIBLE;
26 options mprint;
MPRINT(CIF): ;
27 %CIF (data= check,out= CIF, time= TT_censor_date, status= binary_amputation, group=binary_gender, event=1, title=CIF
27 ! curves);
MPRINT(CIF): options nonotes;
MPRINT(CIF): proc contents data=check noprint out=_c;
MPRINT(CIF): run;
MPRINT(CIF): data _null_;
MPRINT(CIF): length x y $32;
MPRINT(CIF): set _c;
MPRINT(CIF): x=lowcase(NAME);
MPRINT(CIF): y=lowcase("TT_censor_date");
MPRINT(CIF): if x=y then do;
MPRINT(CIF): if TYPE=1 then call symput('TimeVar', put(0,1.));
MPRINT(CIF): else call symput('TimeVar', put(2,1.));
MPRINT(CIF): end;
MPRINT(CIF): y=lowcase("binary_amputation");
MPRINT(CIF): if x=y then do;
MPRINT(CIF): if TYPE=1 then call symput('StatusVar', put(0,1.));
MPRINT(CIF): else call symput('StatusVar', put(2,1.));
MPRINT(CIF): end;
MPRINT(CIF): y=lowcase("binary_gender");
MPRINT(CIF): if x=y then do;
MPRINT(CIF): if TYPE=1 then call symput('GroupVar', put(0,1.));
MPRINT(CIF): else call symput('GroupVar', put(2,1.));
MPRINT(CIF): end;
MPRINT(CIF): ;
MPRINT(CIF): call symput('StrataVar', put(3,1.));
MPRINT(CIF): run;
MPRINT(CIF): data _null_;
MPRINT(CIF): list= lowcase(symget('options'));
MPRINT(CIF): i = index(list, 'noplot');
2 The SAS System 08:06 Thursday, October 1, 2020

MPRINT(CIF): if i then substr(list, i, 6) = ' ';
MPRINT(CIF): call symput('noplotflag', put(i gt 0, 1.));
MPRINT(CIF): i = index(list, 'plotcl');
MPRINT(CIF): if i then substr(list, i, 6) = ' ';
MPRINT(CIF): call symput('plotclflag', put(i gt 0, 1.));
MPRINT(CIF): i = index(list, 'notest');
MPRINT(CIF): if i then substr(list, i, 6) = ' ';
MPRINT(CIF): call symput('notestflag', put(i gt 0, 1.));
MPRINT(CIF): i = index(list, 'nocifest');
MPRINT(CIF): if i then substr(list, i, 😎 = ' ';
MPRINT(CIF): call symput('nocifestflag', put(i gt 0, 1.));
MPRINT(CIF): alpha=.05;
MPRINT(CIF): alpha=.05;
MPRINT(CIF): call symput('Confidence',trim(put(100*(1-alpha),best8. -l)));
MPRINT(CIF): ne=countw(symget('event'),' ');
MPRINT(CIF): call symput('ne',put(ne,best8. -l));
MPRINT(CIF): ncens=countw(symget('censored'),' ');
MPRINT(CIF): call symput('ncens',put(ncens,best8. -l));
MPRINT(CIF): run;
MPRINT(CIF): data _null_;
MPRINT(CIF): set check;
MPRINT(CIF): array _event_[1 ] _temporary_(1);
MPRINT(CIF): array censored[1 ] _temporary_(0);
MPRINT(CIF): ;
MPRINT(CIF): zevent=0;
MPRINT(CIF): zcensored=0;
MPRINT(CIF): do i=1 to 1 ;
MPRINT(CIF): if binary_amputation = _event_[i] then do;
MPRINT(CIF): zevent=1;
MPRINT(CIF): goto skip1;
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): skip1:;
MPRINT(CIF): do i=1 to 1 ;
MPRINT(CIF): if binary_amputation = censored[i] then do;
MPRINT(CIF): zcensored=1;
MPRINT(CIF): go to skip2;
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): skip2:;
MPRINT(CIF): if zevent=1 and zcensored=1 then do;
MPRINT(CIF): call symput('s11',trim(left(put(binary_amputation,best8.))));
MPRINT(CIF): stop;
MPRINT(CIF): end;
MPRINT(CIF): if zevent=1 then do;
MPRINT(CIF): call symput('nev',put(1,1.));
MPRINT(CIF): end;
MPRINT(CIF): run;
MPRINT(CIF): run;
MPRINT(CIF): data _null_;
MPRINT(CIF): set check;
MPRINT(CIF): length l $ 60;
MPRINT(CIF): call vname(TT_censor_date, l);
MPRINT(CIF): call symputx('tname', l, 'L');
MPRINT(CIF): call label(TT_censor_date, l);
MPRINT(CIF): call symputx('tlabel', l, 'L');
MPRINT(CIF): call vname(binary_gender, l);
MPRINT(CIF): call symputx('gname', l, 'L');
3 The SAS System 08:06 Thursday, October 1, 2020

MPRINT(CIF): call label(binary_gender, l);
MPRINT(CIF): call symputx('glabel',l , 'L');
MPRINT(CIF): call symputx('grpFmt', VFORMAT(binary_gender));
MPRINT(CIF): call symputx('stratlabel',"Strata" , 'L');
MPRINT(CIF): call symputx('stratname', "Strata", 'L');
MPRINT(CIF): ;
MPRINT(CIF): run;
MPRINT(CIF): data _d(drop=binary_gender);
MPRINT(CIF): set check;
MPRINT(CIF): fbinary_gender= put(binary_gender, BEST12.);
MPRINT(CIF): IF CMISS(TT_censor_date,binary_amputation, fbinary_gender) > 0 THEN DELETE;
MPRINT(CIF): run;
MPRINT(CIF): data _null_;
MPRINT(CIF): call symputx('nobs0',nobs0);
MPRINT(CIF): stop;
MPRINT(CIF): set check nobs=nobs0;
MPRINT(CIF): run;
MPRINT(CIF): data _null_;
MPRINT(CIF): call symputx('nobs1',nobs1);
MPRINT(CIF): stop;
MPRINT(CIF): set _d nobs=nobs1;
MPRINT(CIF): run;
ERROR: Procedure IML not found.
MPRINT(CIF): proc iml;
MPRINT(CIF): use _d;
MPRINT(CIF): read all var{TT_censor_date} into time;
MPRINT(CIF): read all var{binary_amputation} into status;
MPRINT(CIF): nobs= nrow(time);
MPRINT(CIF): read all var{fbinary_gender} into group;
MPRINT(CIF): strat= j(nobs,1,1);
MPRINT(CIF): close _d;
MPRINT(CIF): * subroutine to calculate the cumulative incidence and variance;
MPRINT(CIF): start estimate_cif(y, causecode) global(time, cif, vcif1, vcif2, n2);
MPRINT(CIF): surv_km= 1;
MPRINT(CIF): v11= 0;
MPRINT(CIF): v21= 0;
MPRINT(CIF): v12= 0;
MPRINT(CIF): v22= 0;
MPRINT(CIF): v13= 0;
MPRINT(CIF): v23= 0;
MPRINT(CIF): cif_pos= 1;
MPRINT(CIF): n= nrow(y);
MPRINT(CIF): nrisk=n;
MPRINT(CIF): ut=unique(y)`;
MPRINT(CIF): n_ut=nrow(ut);
MPRINT(CIF): cif= j(n2,1,0);
MPRINT(CIF): vcif1= j(n2,1,0);
MPRINT(CIF): vcif2= j(n2,1,0);
MPRINT(CIF): do i=1 to n_ut;
MPRINT(CIF): *compute the number of events of interest and competing events;
MPRINT(CIF): nevent=sum(causecode[loc(y=ut[i])]=1);
MPRINT(CIF): ncompetevent=sum(causecode[loc(y=ut[i])]=2);
MPRINT(CIF): n_allevents = nevent+ ncompetevent;
MPRINT(CIF): *compute survival function and cumulative incidence function;
MPRINT(CIF): if n_allevents^= 0 then do;
MPRINT(CIF): *overall survival changes whenever a failure occurs;
MPRINT(CIF): if (i>1) then nrisk =n - min(loc(y=ut[i]))+1 ;
MPRINT(CIF): surv_km_n= surv_km* (nrisk- n_allevents)/ nrisk;
4 The SAS System 08:06 Thursday, October 1, 2020

MPRINT(CIF): if nevent> 0 then do;
MPRINT(CIF): cif_pos= cif_pos +1;
MPRINT(CIF): cif[cif_pos]= cif[cif_pos-1]+ surv_km * nevent/ nrisk;
MPRINT(CIF): end;
MPRINT(CIF): * variance estimator using delta method- (10.12) in Marubini and Valsecchi (1995);
MPRINT(CIF): * Analysing Survival Data from Clinical Trials and Observational Studies;
MPRINT(CIF): t1=0;
MPRINT(CIF): if (nrisk- n_allevents>0) then t1= n_allevents/ nrisk/ (nrisk- n_allevents);
MPRINT(CIF): t2= surv_km* nevent/ nrisk/ nrisk;
MPRINT(CIF): t3= surv_km* (1- nevent/ nrisk)* t2;
MPRINT(CIF): t4= cif[cif_pos]* cif[cif_pos];
MPRINT(CIF): v11= v11+ t1;
MPRINT(CIF): v12= v12-2* (cif[cif_pos]* t1+ t2);
MPRINT(CIF): v13= v13+ t4* t1+2* cif[cif_pos]* t2 + t3;
MPRINT(CIF): vcif1[cif_pos]= t4* v11+ cif[cif_pos]* v12+ v13;
MPRINT(CIF): *variance estimator using counting process- Gray (1988);
MPRINT(CIF): if (ncompetevent> 0 & surv_km_n> 0) then do;
MPRINT(CIF): vt1=1;
MPRINT(CIF): if( ncompetevent > 1) then vt1= 1- (ncompetevent -1)/(nrisk-1);
MPRINT(CIF): vt2= surv_km* surv_km* vt1* ncompetevent/(nrisk* nrisk);
MPRINT(CIF): vt3= 1/ surv_km_n;
MPRINT(CIF): vt4= cif[cif_pos]/ surv_km_n;
MPRINT(CIF): v21= v21+ vt2* vt4* vt4;
MPRINT(CIF): v22= v22+ vt2* vt3* vt4;
MPRINT(CIF): v23= v23+ vt2* vt3* vt3;
MPRINT(CIF): end;
MPRINT(CIF): if (nevent> 0) then do;
MPRINT(CIF): vt1=1;
MPRINT(CIF): if( nevent> 1 ) then vt1= 1-(nevent-1)/(nrisk-1);
MPRINT(CIF): vt2= surv_km* surv_km* vt1* nevent/(nrisk* nrisk);
MPRINT(CIF): if surv_km_n> 0 then vt3= 1/ surv_km_n;
MPRINT(CIF): else vt3= 0;
MPRINT(CIF): vt4= 1+ vt3* cif[cif_pos];
MPRINT(CIF): v21= v21+ vt2* vt4* vt4;
MPRINT(CIF): v22= v22+ vt2* vt3* vt4;
MPRINT(CIF): v23= v23+ vt2* vt3* vt3;
MPRINT(CIF): vcif2[cif_pos]= v21 -2*cif[cif_pos]*v22 + cif[cif_pos]*cif[cif_pos]*v23;
MPRINT(CIF): end;
MPRINT(CIF): surv_km= surv_km_n;
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): if cif_pos< n2 then do;
MPRINT(CIF): cif_pos= cif_pos+1;
MPRINT(CIF): *time[cif_pos]= ut[n_ut];
MPRINT(CIF): cif[cif_pos]= cif[cif_pos-1];
MPRINT(CIF): vcif1[cif_pos]= vcif1[cif_pos-1];
MPRINT(CIF): vcif2[cif_pos]= vcif2[cif_pos-1];
MPRINT(CIF): end;
MPRINT(CIF): if (sum(vcif1<0)>0) then vcif1[loc(vcif1<0)]=0;
MPRINT(CIF): if (sum(vcif2<0)>0) then vcif2[loc(vcif2<0)]=0;
MPRINT(CIF): vcif1= sqrt(vcif1);
MPRINT(CIF): vcif2= sqrt(vcif2);
MPRINT(CIF): finish estimate_cif;
MPRINT(CIF): start test_ksample(y, causecode, ig, rho) global(score, vcov);
MPRINT(CIF): * y is the failure times (sorted in ascending order) * causecode is cause indicator * (= 0 if censored, =1 if failed
from the cause of interest, * 2 if failed from some other causes.) * ig denotes group membership * rho is the power of the weight
function in the test statistic * ng denotes the number of groups, ng1= ng-1;
MPRINT(CIF): ng= ncol(unique(ig));
5 The SAS System 08:06 Thursday, October 1, 2020

MPRINT(CIF): * risk set size in each at the current failure time (= sample size at 0);
MPRINT(CIF): nrisk= j(ng,1,0);
MPRINT(CIF): do i= 1 to ng;
MPRINT(CIF): nrisk[i]= nrisk[i] + sum(ig=i);
MPRINT(CIF): end;
MPRINT(CIF): ng1=ng-1;
MPRINT(CIF): ng2= ng* ng1/ 2;
MPRINT(CIF): score= j(ng1,1,0);
MPRINT(CIF): vcov= j(ng2,1,0);
MPRINT(CIF): l= 0;
MPRINT(CIF): cifgleft= j(ng,1,0);
MPRINT(CIF): cifg= j(ng,1,0);
MPRINT(CIF): cif0left= 0;
MPRINT(CIF): cif0= 0;
MPRINT(CIF): vtvec= j(ng,1,0);
MPRINT(CIF): skmgleft= j(ng,1,1);
MPRINT(CIF): skmg= j(ng,1,1);
MPRINT(CIF): vtmatrix= j(ng1,ng,0);
MPRINT(CIF): c= j(ng,ng,0);
MPRINT(CIF): ll= 1;
MPRINT(CIF): ut=unique(y)`;
MPRINT(CIF): n_ut=nrow(ut);
MPRINT(CIF): do i=1 to n_ut;
MPRINT(CIF): d= j(3,ng,0);
MPRINT(CIF): yloc=loc(y=ut[i]);
MPRINT(CIF): do ii= yloc[1] to yloc[ncol(yloc)];
MPRINT(CIF): k= causecode[ii]+1;
MPRINT(CIF): * causes code:0, 1, 2;
MPRINT(CIF): d[k,ig[ii]]= d[k,ig[ii]] +1;
MPRINT(CIF): end;
MPRINT(CIF): nd1= d[2,+];
MPRINT(CIF): nd2= d[3,+];
MPRINT(CIF): if (nd1^= 0 | nd2^= 0) then do;
MPRINT(CIF): *hdot is sum(hhat), Rdot is sum(R), skmgleft is Shat, nrisk is Y, cifgleft is CIF;
MPRINT(CIF): hdot= 0;
MPRINT(CIF): Rdot= 0;
MPRINT(CIF): do g= 1 to ng;
MPRINT(CIF): if (nrisk[g]> 0) then do;
MPRINT(CIF): td= d[2,g] + d[3,g];
MPRINT(CIF): skmg[g]= skmgleft[g]* (nrisk[g]- td)/ nrisk[g];
MPRINT(CIF): cifg[g]= cifgleft[g]+ skmgleft[g]* d[2,g]/ nrisk[g];
MPRINT(CIF): hdot= hdot+ nrisk[g]/ skmgleft[g];
MPRINT(CIF): Rdot= Rdot+ nrisk[g]* (1 - cifgleft[g])/ skmgleft[g];
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): cif0= cif0left+ nd1/hdot;
MPRINT(CIF): grho= (1- cif0left)**rho;
MPRINT(CIF): * score statistic;
MPRINT(CIF): do g=1 to ng1;
MPRINT(CIF): if (nrisk[g]> 0) then score[g]= score[g]+ grho* (d[2,g]- nd1* nrisk[g]* (1- cifgleft[g])/ skmgleft[g]/ Rdot);
MPRINT(CIF): end;
MPRINT(CIF): a= j(ng, ng,0);
MPRINT(CIF): do g= 1 to ng;
MPRINT(CIF): if (nrisk[g]> 0) then do;
MPRINT(CIF): t1= nrisk[g]/ skmgleft[g];
MPRINT(CIF): a[g,g]= grho* t1* (1- t1/ hdot);
MPRINT(CIF): c[g,g]= c[g,g]+ a[g,g]* nd1/hdot/(1- cif0left);
MPRINT(CIF): k= g +1;
6 The SAS System 08:06 Thursday, October 1, 2020

MPRINT(CIF): *if (k<= ng) then do j= k to ng;
MPRINT(CIF): do j= g+1 to ng;
MPRINT(CIF): if (nrisk[j]> 0) then do;
MPRINT(CIF): a[g,j]= - grho* t1* nrisk[j]/ skmgleft[j]/ hdot;
MPRINT(CIF): a[j,g]= a[g,j];
MPRINT(CIF): c[g,j]= c[g,j]+ a[g,j]* nd1/ hdot/ (1 - cif0left);
MPRINT(CIF): c[j,g]= c[g,j];
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): * variance estimators;
MPRINT(CIF): if nd1> 0 then do k=1 to ng;
MPRINT(CIF): if (nrisk[k]> 0) then do;
MPRINT(CIF): if skmg[k]> 0 then vt1= 1- (1- cif0)/ skmg[k];
MPRINT(CIF): else vt1= 1;
MPRINT(CIF): if nd1> 1 then vt2= 1- (nd1-1)/ (hdot* skmgleft[k]-1);
MPRINT(CIF): else vt2= 1;
MPRINT(CIF): vt3= vt2* skmgleft[k]* nd1/ (hdot* nrisk[k]);
MPRINT(CIF): vtvec[k]= vtvec[k]+ vt1* vt1* vt3;
MPRINT(CIF): do g= 1 to ng1;
MPRINT(CIF): vt4= a[g,k]- vt1* c[g,k];
MPRINT(CIF): vtmatrix[g,k]= vtmatrix[g,k]+ vt4* vt1* vt3;
MPRINT(CIF): do j=1 to g;
MPRINT(CIF): l= g* (g-1)/ 2+ j;
MPRINT(CIF): vt5= a[j,k]- vt1* c[j,k];
MPRINT(CIF): vcov[l]= vcov[l]+ vt3* vt4* vt5;
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): if (nd2^= 0) then do k=1 to ng;
MPRINT(CIF): if (skmg[k]> 0 & d[3,k]> 0) then do;
MPRINT(CIF): vt1= (1- cif0)/ skmg[k];
MPRINT(CIF): vt2= 1;
MPRINT(CIF): if (d[3,k]> 1) then vt2= 1- (d[3,k] -1)/ (nrisk[k]-1);
MPRINT(CIF): vt3= vt2* ((skmgleft[k]** 2)* d[3,k])/ (nrisk[k]** 2);
MPRINT(CIF): vtvec[k]= vtvec[k]+ vt1* vt1* vt3;
MPRINT(CIF): do g=1 to ng1;
MPRINT(CIF): vt4= vt1* c[g,k];
MPRINT(CIF): vtmatrix[g,k]= vtmatrix[g,k]- vt4* vt1* vt3;
MPRINT(CIF): do j=1 to g;
MPRINT(CIF): l= g* (g-1)/ 2+ j;
MPRINT(CIF): vt5= vt1* c[j,k];
MPRINT(CIF): vcov[l]= vcov[l]+ vt3* vt4* vt5;
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): *update the risk sets and the index of the next failure time;
MPRINT(CIF): do ii= yloc[1] to yloc[ncol(yloc)];
MPRINT(CIF): nrisk[ig[ii]]= nrisk[ig[ii]] -1;
MPRINT(CIF): end;
MPRINT(CIF): cif0left= cif0;
MPRINT(CIF): cifgleft= cifg;
MPRINT(CIF): skmgleft= skmg;
MPRINT(CIF): end;
7 The SAS System 08:06 Thursday, October 1, 2020

MPRINT(CIF): pos= 0;
MPRINT(CIF): do g= 1 to ng1;
MPRINT(CIF): do j= 1 to g;
MPRINT(CIF): pos= pos+1;
MPRINT(CIF): do k= 1 to ng;
MPRINT(CIF): vcov[pos]= vcov[pos]+ c[g,k]* c[j,k]* vtvec[k];
MPRINT(CIF): vcov[pos]= vcov[pos]+ c[g,k]* vtmatrix[j,k];
MPRINT(CIF): vcov[pos]= vcov[pos]+ c[j,k]* vtmatrix[g,k];
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): finish test_ksample;
MPRINT(CIF): * subroutines end and the calculation starts here;
MPRINT(CIF): * status need to be numerical value;
MPRINT(CIF): x= time|| status;
MPRINT(CIF): *call sort(x, {1 2});
MPRINT(CIF): call sortndx(sidx, x, {1 2});
MPRINT(CIF): x=x[sidx,];
MPRINT(CIF): group=group[sidx];
MPRINT(CIF): strat=strat[sidx];
MPRINT(CIF): ugg= unique(group);
MPRINT(CIF): ng= ncol(ugg);
MPRINT(CIF): call symput('ng',left(char(ng)));
MPRINT(CIF): * censind= 0 if censored, =1 if failed;
MPRINT(CIF): censList={0}`;
MPRINT(CIF): eventList={1}`;
MPRINT(CIF): censind=j(nrow(x),1,0);
MPRINT(CIF): eventind=censind;
MPRINT(CIF): do i= 1 to 1 ;
MPRINT(CIF): censind= censind |(x[,2]= censList[i]);
MPRINT(CIF): end;
MPRINT(CIF): do i= 1 to 1 ;
MPRINT(CIF): eventind= eventind |(x[,2]= eventList[i]);
MPRINT(CIF): end;
MPRINT(CIF): causecode= 2* (^censind)- eventind;
MPRINT(CIF): * prepare the data;
MPRINT(CIF): x= x|| censind|| causecode;
MPRINT(CIF): if ng> 1 then do;
MPRINT(CIF): ng1= ng -1;
MPRINT(CIF): ng2= ng* ng1/ 2;
MPRINT(CIF): vv= j(ng1,ng1,0);
MPRINT(CIF): *the final covariance matrix;
MPRINT(CIF): vcov_st= j(ng2,1,0);
MPRINT(CIF): vcov= vcov_st;
MPRINT(CIF): *vcov_st for each stratum, vs add v across strata ;
MPRINT(CIF): score_st= j(ng1,1,0);
MPRINT(CIF): score= score_st;
MPRINT(CIF): *s is test statiatics by stratum,ss add s across strata;
MPRINT(CIF): end;
MPRINT(CIF): ust= unique(strat);
MPRINT(CIF): nstrata= ncol(ust);
MPRINT(CIF): call symput('nstrata',left(char(nstrata)));
MPRINT(CIF): if (0=0) then do;
MPRINT(CIF): do k= 1 to nstrata;
MPRINT(CIF): do g= 1 to ng;
MPRINT(CIF): gind= (group= ugg[g]);
MPRINT(CIF): *ncg= sum(gind);
MPRINT(CIF): * subset of data for group g and stratum k;
8 The SAS System 08:06 Thursday, October 1, 2020

MPRINT(CIF): grpstra=(gind= 1) & (strat= ust[k]) & (x[,4]=1);
MPRINT(CIF): if (sum(grpstra)>0) then do;
MPRINT(CIF): xsub= x[loc((gind= 1) & (strat= ust[k])), ];
MPRINT(CIF): * aa are failure times for cause 1, n2 is the length of CIF;
MPRINT(CIF): aa= xsub[loc(xsub[,4]= 1), 1];
MPRINT(CIF): n2 = ncol(unique(aa))+2;
MPRINT(CIF): run estimate_cif(xsub[,1], xsub[,4]);
ERROR: Unrecognized form of the RUN statement. Use either RUN; or RUN CANCEL;.
MPRINT(CIF): time1=0//(unique(aa))`//xsub[nrow(xsub),1];
MPRINT(CIF): tmp= time1|| cif|| vcif1|| vcif2;
MPRINT(CIF): *time,CI,variance,group;
MPRINT(CIF): if (g= 1 & k=1) then do;
MPRINT(CIF): cifEST= tmp;
MPRINT(CIF): grpLabel=j(n2,1,ugg[g]);
MPRINT(CIF): if(nstrata>1) then stratLabel=j(n2,1,ust[k]);
MPRINT(CIF): end;
MPRINT(CIF): else do;
MPRINT(CIF): cifEST= cifEST//tmp;
MPRINT(CIF): grpLabel= grpLabel//j(n2,1,ugg[g]);
MPRINT(CIF): if(nstrata>1) then stratLabel=stratLabel//j(n2,1,ust[k]);
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): *cifloc=loc(cifEST[,2]>0);
MPRINT(CIF): cifloc=loc((cifEST[,2]>1e-12) & (cifEST[,2]<exp(-1e-12)));
MPRINT(CIF): ncif= nrow(cifEST);
MPRINT(CIF): lowci=j(ncif, 1, .);
MPRINT(CIF): upci =j(ncif, 1, .);
MPRINT(CIF): z=probit(1-.05/2.0);
MPRINT(CIF): *lowci[cifloc] = cifEST[cifloc, 2]##exp((-z*cifEST[cifloc, 3]) /(cifEST[cifloc,2]#LOG(cifEST[cifloc,2])));
MPRINT(CIF): *upci[cifloc] = cifEST[cifloc, 2]##exp((z*cifEST[cifloc, 3]) /(cifEST[cifloc,2]#LOG(cifEST[cifloc,2])));
MPRINT(CIF): if (1=1) then do;
MPRINT(CIF): lowci[cifloc] = cifEST[cifloc, 2]##exp((-z*cifEST[cifloc, 4]) /(cifEST[cifloc,2]#LOG(cifEST[cifloc,2])));
MPRINT(CIF): upci[cifloc] = cifEST[cifloc, 2]##exp((z*cifEST[cifloc, 4]) /(cifEST[cifloc,2]#LOG(cifEST[cifloc,2])));
MPRINT(CIF): cifEST=cifEST[, (1:2||4)];
MPRINT(CIF): cifEST = cifEST || lowci || upci;
MPRINT(CIF): create CIFplot from cifEST[colname={"TT_censor_date" "CIF" "StdErr" "LowerCI" "UpperCI"}];
MPRINT(CIF): end;
MPRINT(CIF): else do;
MPRINT(CIF): lowci[cifloc] = cifEST[cifloc, 2]##exp((-z*cifEST[cifloc, 3]) /(cifEST[cifloc,2]#LOG(cifEST[cifloc,2])));
MPRINT(CIF): upci[cifloc] = cifEST[cifloc, 2]##exp((z*cifEST[cifloc, 3]) /(cifEST[cifloc,2]#LOG(cifEST[cifloc,2])));
MPRINT(CIF): cifEST=cifEST[,(1:3)];
MPRINT(CIF): cifEST = cifEST|| lowci || upci;
MPRINT(CIF): create CIFplot from cifEST[colname={"TT_censor_date" "CIF" "StdErr" "LowerCI" "UpperCI"}];
MPRINT(CIF): end;
MPRINT(CIF): append from cifEST;
MPRINT(CIF): close CIFplot;
MPRINT(CIF): create _outgrpLabel from grpLabel[colname={"binary_gender"}] ;
MPRINT(CIF): append from grpLabel;
MPRINT(CIF): close _outgrpLabel;
MPRINT(CIF): if (nstrata>1) then do;
MPRINT(CIF): create outstratLabel from stratLabel[colname={"Strata"}] ;
MPRINT(CIF): append from stratLabel;
MPRINT(CIF): close outstratLabel;
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): if ( ng>1 &(^0)) then do;
9 The SAS System 08:06 Thursday, October 1, 2020

MPRINT(CIF): grpcode=j(nrow(x), 1, 0);
MPRINT(CIF): do g= 1 to ng;
MPRINT(CIF): grpcode[loc(group= ugg[g])]=g;
MPRINT(CIF): end;
MPRINT(CIF): do k= 1 to nstrata;
MPRINT(CIF): * subset of data for stratum k;
MPRINT(CIF): xsub= x[loc(strat= ust[k]), ];
MPRINT(CIF): grpcodesub=grpcode[loc(strat= ust[k])];
MPRINT(CIF): if (ncol(unique(grpcodesub))=ng) then do;
MPRINT(CIF): Run test_ksample(xsub[,1], xsub[,4], grpcodesub, 0);
ERROR: Unrecognized form of the RUN statement. Use either RUN; or RUN CANCEL;.
MPRINT(CIF): score_st= score_st+ score;
MPRINT(CIF): vcov_st= vcov_st+ vcov;
MPRINT(CIF): end;
MPRINT(CIF): else call symput('inconsistentgrpnumflag',left(char(1)));
MPRINT(CIF): end;
MPRINT(CIF): pos= 0;
MPRINT(CIF): do i= 1 to ng1;
MPRINT(CIF): do j= 1 to i;
MPRINT(CIF): pos= pos+1;
MPRINT(CIF): vv[i,j]= vcov_st[pos];
MPRINT(CIF): vv[j,i]= vv[i,j];
MPRINT(CIF): end;
MPRINT(CIF): end;
MPRINT(CIF): * test statistic and p-value;
MPRINT(CIF): test_stat= score_st`* ginv(vv)* score_st;
MPRINT(CIF): df= ng1;
MPRINT(CIF): pval= 1- probchi(test_stat, df);
MPRINT(CIF): Test= test_stat || df || pval;
MPRINT(CIF): create TestResult from Test[colname={ "test_stat" "df" "pval"}];
MPRINT(CIF): append from Test;
MPRINT(CIF): close TestResult;
MPRINT(CIF): end;
MPRINT(CIF): quit;
MPRINT(CIF): data CIFplot;
MPRINT(CIF): merge _outgrpLabel CIFplot;
ERROR: File WORK._OUTGRPLABEL.DATA does not exist.
MPRINT(CIF): if (0) then set check(keep=TT_censor_date);
MPRINT(CIF): run;
WARNING: The data set WORK.CIFPLOT may be incomplete. When this step was stopped there were 0 observations and 1 variables.
WARNING: Data set WORK.CIFPLOT was not replaced because this step was stopped.
WARNING: Apparent symbolic reference NSTRATA not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
(&nstrata>1)
ERROR: The macro CIF will stop executing.
28
29
30 GOPTIONS NOACCESSIBLE;
31 %LET _CLIENTTASKLABEL=;
32 %LET _CLIENTPROCESSFLOWNAME=;
33 %LET _CLIENTPROJECTPATH=;
34 %LET _CLIENTPROJECTPATHHOST=;
35 %LET _CLIENTPROJECTNAME=;
36 %LET _SASPROGRAMFILE=;
37 %LET _SASPROGRAMFILEHOST=;
38
39 ;*';*";*/;quit;run;
40 ODS _ALL_ CLOSE;
10 The SAS System 08:06 Thursday, October 1, 2020

41
42
43 QUIT; RUN;

 

My question am I calling the macro incorrectly causing the error or is it an error within the macro itself? Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
CurtisMackWSIPP
Lapis Lazuli | Level 10

I know nothing about this macro, but there is a very telling error in your log

 

ERROR: Procedure IML not found.

Do you have IML installed?

View solution in original post

1 REPLY 1
CurtisMackWSIPP
Lapis Lazuli | Level 10

I know nothing about this macro, but there is a very telling error in your log

 

ERROR: Procedure IML not found.

Do you have IML installed?

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1425 views
  • 3 likes
  • 2 in conversation