Programming the statistical procedures from SAS

PHREG log transformation

New User
Posts: 1

PHREG log transformation


I'm using proc phreg to model several covariates of an outcome. The continuous variables need to be log transformed, but sometimes when I run the code it works while other times I get the following error:

ERROR: An illegal argument is used in the function call in statement number 1 at line 13

       column 1.

       The statement was:

    1     (13:1)     logpreedin = LOG( preedin=0 )

I get that I can't expect SAS to calculate the log of zero, but can someone explain to me why it sometimes shows outputs for both the model and assess statements with logpreedin and sometimes I get the above error?

Here's the code:

proc phreg data=lchs.thesis_event;

class trimst: outcome;


model time*pregint24(0)=depo bfeed outcome prev_unplanned logpreedin postedin prop_fps kept_ps sex_nocondom/ties=efron;

assess var=(logpreedin) ph/resample;



Super Contributor
Posts: 301

Re: PHREG log transformation

Hello Than,

I have two suggestions:

1) I think the only reason for why it sometimes Works and sometimes not is the random samples in the assessment. If you dont need to assess the functional form, then you shold omit the assessment statement, and the error will most likely disappear.

2) Also, since preedin is not timedependent, you should calculate logpreedin in a dataset before you run PHREG. Then, phreg will see logpreedin as any other fixed covariates, and the log-transformation will not be used in the assessment neithter (becase logpreedin is then already a transformed variable). Therefore, defining the logpredin in a dataset should also remove the error.

Good luck.


Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation