Date: Fri, 19 Dec 2008 06:58:09 -0600
Reply-To: torche@i-minds.be
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Francois Torche <torche@I-MINDS.BE>
Subject: PHREG SAS 8 vs SAS 9
Content-Type: text/plain;charset=utf-8
Hi All,
The following code runs in less than a minute on SAS 8.2 and more than 11
on SAS 9. I know it's something related to PHREG but I don't know why?
Any help would be appreciated ;-)
Thanks,
François
<CODE>
PROC FORMAT;
VALUE dis_fmt 1='Case' 0='Control';
VALUE exp_fmt 1='Vaccntd' 0='Unvaccntd';
RUN;
DATA test (label = Output Case-Control Macro 19DEC08:13:18:12 Search B);
Ncases = 200;
C_C_Rat = 2;
Vac_Cov = 0.8;
Market_sh = 1;
OR = 0.5;
Alpha = 0.05;
_theta = 2.5;
Limit = 1;
Uplow = "U";
OUTPUT;
RUN;
DATA test;
SET test nobs=last;
IF _N_ = last THEN CALL SYMPUT("NofTest",put(_N_,best.));
if (Vac_cov * OR)/(1-Vac_cov+Vac_cov * OR) > 1 then delete;
RD = (OR-1) * Vac_cov * (1-Vac_cov) / (1-Vac_cov + OR * Vac_cov);
Zalpha = PROBIT(1-Alpha/2);
LABEL Ncases = "Number of cases" C_C_rat = "Case-control ratio" VAC_COV =
"Vaccination coverage - baseline - P(vaccinated|not ill)" OR = "Odds
Ratio" Alpha = "Alpha
Error - Type I" Limit = "Upper or Lower limit for the confidence interval
of OR or VE" Uplow =
"Say if Limit is an upper or lower limit" ;
RUN;
ODS noresults;
ODS LISTING CLOSE;
DATA sample (KEEP = simulat disease exposure match vaccinated);
seed = 0;
ncaseold=0;
nctrlold=0;
pcases = (0.8*0.5) / (1 - (0.8*(1-0.5)));
pvacc = 1;
DO i=1 TO 10/*1000*/;
**run this loop from the 1st to the ith simulation;
simulat = i;
**set the variable simulation to the simulation number;
DO j=1+ncaseold TO 200+ncaseold;
**run this loop to create from to 1st to the jth case;
match=j;
disease=1;
CALL RANBIN(seed,1,pcases,exposure);
IF exposure=1 THEN DO;
vaccinated = 1;
IF pvacc NE 1 THEN DO;
CALL RANBIN(seed,1,pvacc,vaccinated);
**vaccinated with the vaccine under study;
IF vaccinated=0 THEN vaccinated=2;
*vaccinated with the other vaccine;
END;
END;
ELSE vaccinated=0;
OUTPUT;
END;
DO k=1+nctrlold TO 200*2+nctrlold;
match=CEIL(k/2);
disease=0;
CALL RANBIN(seed,1,0.8,exposure);
IF exposure=1 THEN DO;
vaccinated = 1;
IF pvacc NE 1 THEN DO;
CALL RANBIN(seed,1,pvacc,vaccinated);
IF vaccinated=0 THEN vaccinated=2;
END;
END;
ELSE vaccinated=0;
OUTPUT;
END;
END;
ncaseold=ncaseold+200;
nctrlold=nctrlold+200*2;
RETAIN ncaseold nctrlold;
format disease dis_fmt. exposure exp_fmt.;
RUN;
DATA Work._Simul_1;
SET sample;
IF vaccinated=2 THEN DELETE;
cas=2-disease;
RUN;
ODS LISTING CLOSE;
* OPTIONS NONOTES;
PROC PHREG DATA=Work._Simul_1 nosummary;
STRATA match;
MODEL cas*disease(0)=exposure/ties=discrete rl alpha=0.05;
BY simulat;
ODS OUTPUT ParameterEstimates=ORRand ;
RUN;
* OPTIONS NOTES;
DATA OR;
SET ORRand;
IF .z < HRUPPERCL < 1 THEN flgLT_up = 1;
ELSE IF HRUPPERCL >= 1 THEN flgLT_up = 0;
RUN;
</CODE>