The PHREG Procedure

Programming Statements

Programming statements are used to create or modify the values of the explanatory variables in the MODEL statement. They are especially useful in fitting models with time-dependent explanatory variables. Programming statements can also be used to create explanatory variables that are not time dependent. For example, you can create indicator variables from a categorical variable and incorporate them into the model. PROC PHREG programming statements cannot be used to create or modify the values of the response variable, the censoring variable, the frequency variable, or the strata variables.

The following DATA step statements are available in PROC PHREG:

  • ABORT;

  • ARRAY arrayname <[ dimensions ]> <$> <variables-and-constants>;

  • CALL name <(expression <, expression …>)>;

  • DELETE;

  • DO <variable = expression <TO expression> <BY expression>> <, expression <TO expression> <BY expression>> …

  • <WHILE expression> <UNTIL expression>;

  • END;

  • GOTO statement-label;

  • IF expression;

  • IF expression THEN program-statement;

  • ELSE program-statement;

  • variable = expression;

  • variable + expression;

  • LINK statement-label;

  • PUT <variable> <=> …;

  • RETURN;

  • SELECT <(expression)>;

  • STOP;

  • SUBSTR(variable, index, length)= expression;

  • WHEN (expression)program-statement;

  • OTHERWISE program-statement;

By default, the PUT statement in PROC PHREG writes results to the Output window instead of the Log window. If you want the results of the PUT statements to go to the Log window, add the following statement before the PUT statements:

  FILE LOG;

DATA step functions are also available. Use these programming statements the same way you use them in the DATA step. For detailed information, see SAS Statements: Reference.

Consider the following example of using programming statements in PROC PHREG. Suppose blood pressure is measured at multiple times during the course of a study investigating the effect of blood pressure on some survival time. By treating the blood pressure as a time-dependent explanatory variable, you are able to use the value of the most recent blood pressure at each specific point of time in the modeling process rather than using the initial blood pressure or the final blood pressure. The values of the following variables are recorded for each patient, if they are available. Otherwise, the variables contain missing values.

Time

survival time

Censor

censoring indicator (with 0 as the censoring value)

BP0

blood pressure on entry to the study

T1

time 1

BP1

blood pressure at T1

T2

time 2

BP2

blood pressure at T2

The following programming statements create a variable BP. At each time T, the value of BP is the blood pressure reading for that time, if available. Otherwise, it is the last blood pressure reading.

proc phreg;
   model Time*Censor(0)=BP;
   BP = BP0;
   if Time>=T1 and T1^=. then BP=BP1;
   if Time>=T2 and T2^=. then BP=BP2;
run;

For other illustrations of using programming statements, see the section Classical Method of Maximum Likelihood and Example 73.6.