turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- my phreg takes forever to run

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-25-2015 03:54 PM

proc phreg data = dm_mty nosummary;

class sex (ref='F') ageg(ref='<30') / param = ref;

model ft*dead(0) = sex ageg xcvd1;

if cvd1=1 & surv_cvd1 < ft then xcvd1=1; else xcvd1=0;

run;

I ran the same program by strata case_phin, without adjusting sex and age. it worked. but I select a subgroup data, no strata, but adjusting sex and age, it just run and run ... no stop.

I need the results for tomorrow's presentation. now I am panic.... Thank you.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-25-2015 04:11 PM

What version of SAS are you using? Consider applying the IF condition outside of the proc and then running the proc phreg.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

11-25-2015 04:32 PM

sas 9.2. The if statemetn is required for this model. the variable is time dependent. I have run this model with STRATA. It worked. it just continue running when strata is removed.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-25-2015 07:24 PM

If you can stratify then you can put the IF statement outside the PROC. That is, essentially, what stratification does.

What exactly are you trying to do?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to plf515

11-26-2015 09:51 AM

You can not put the "IF" outside the PHREG. The problem is because that the condition is dependent on the underlying timeaxis. Putting it outside the proc will introduce future-dependent covariates in the model, which obviously gives wrong results.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-26-2015 09:43 AM - edited 11-26-2015 09:44 AM

Don't panic. There is a good trick you can use.

Because you define your covariate inside phreg the algorithm it use will change to a slower algorithm were calculation speed is proportional to N^2. (N=number of events).

What you can do is to aggregate your data on *riskset, *then you get a dataset with a timevariable that indicate the time of the riskset. then you can define your covariate in a dataset before using phreg. calculation time of Phreg will then only be proportional to N. It is not that simple, but you can use my macro Here: how to speed up phreg.

Using the macro your program will be much like this example:

```
data simulation;
do covariate1=0 to 1;
do covariate2=0 to 1;
do i=1 to 100;
*the timevariables are created such that ties will happens often;
t=floor(-1000*log(ranuni(-1))/exp(0.1*(covariate1=1)+0.2*(covariate2=1)))/10+0.1;
*a censoring variable c;
c=-100*log(ranuni(-1));
*events happens if survival time are less than censoring time;
event=(t<c);
exit=min(t,c);
entry=0;
output;
end;
end;
end;
drop i t c;
run;
quit;
*Example , a timedependent effect;
proc phreg data=simulation nosummary;
covariate1_1=(exit<=5)*covariate1;
covariate1_2=(exit>5)*covariate1;
model (entry exit)*event(0)= covariate1_1 covariate1_2;
run;
*equivalent to:;
%coxaggregate(data=simulation,output=dataout,entry=entry,exit=exit,event=event,covariate=covariate1);
data dataout;
set dataout;
more5=(time>5);
run;
proc phreg data=dataout nosummary;
class covariate1 more5/param=glm ;
model dummytime*dummytime(2)= covariate1*more5 ;
hazardratio covariate1/ at( more5=all);
strata time ;
weight weight;
run;
```

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to JacobSimonsen

11-26-2015 10:16 AM

I just noted that "weights" were not possible in SAS 9.2. You get the university edition for free, which has the most recent version of SAS/STAT.

Unfortunately, without weights it is not possible to reduce the calculation time to be linear with number of events in a Cox-regression with timedependent variables.

It is correct that you can use STRATA on the timedependent variable, unless the timedependent variable is the variable of interest (you dont get estiamtes for variables in STRATA).

Unfortunately, without weights it is not possible to reduce the calculation time to be linear with number of events in a Cox-regression with timedependent variables.

It is correct that you can use STRATA on the timedependent variable, unless the timedependent variable is the variable of interest (you dont get estiamtes for variables in STRATA).

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to JacobSimonsen

11-26-2015 11:16 AM

Thank you. It is extremely helpful. I will figure out the maicro and let you know. Thanks again for the timely response.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-27-2015 03:17 AM

Actually, there is one more possibibility that may be even easier than using the macro i suggested above.

because your time-dependent variable is piecewise constant, you can make your dataset such that you split observations at the time where the covariate change it values. That is, you should have a entry and a exit variable such such that that the total observation time is the same. be aware that person that has event should be censored at time of change of covariate and only have a eventtime on the original eventtime. Then you can use phreg with delayed entry:

model (entry exit)*event(0)=covariates

Then you avoid creating timedependent variables inside phreg.

The method will be fast if you use the FAST-option :

PROC PHREG DATA=mydata FAST;

...

RUN;

It was introduced in the latest release from august this year, but included in the university edition. Without the fast-option the method with delayed entry will not be faster than using timedependent variables.

because your time-dependent variable is piecewise constant, you can make your dataset such that you split observations at the time where the covariate change it values. That is, you should have a entry and a exit variable such such that that the total observation time is the same. be aware that person that has event should be censored at time of change of covariate and only have a eventtime on the original eventtime. Then you can use phreg with delayed entry:

model (entry exit)*event(0)=covariates

Then you avoid creating timedependent variables inside phreg.

The method will be fast if you use the FAST-option :

PROC PHREG DATA=mydata FAST;

...

RUN;

It was introduced in the latest release from august this year, but included in the university edition. Without the fast-option the method with delayed entry will not be faster than using timedependent variables.