Programming the statistical procedures from SAS

time-varying covariates

Reply
N/A
Posts: 0

time-varying covariates

Hello,

I am trying to look at the effect of a drug on an outcome. The drug was used at different intervals through the observation period. I set up the data as below

NODAT Duration RAS1 RAS2 RAS3 etc for use in months 1, 2, 3 etc

and I used this syntax

proc phreg data=_proj_.imported;
model DURATION*NODAT(0) = cum AGE / risklimits;
array cum (*) RAS1-RAS12;
do i = 1 to 12;
if DURATION=i then cum=RAS; end; run;

and keep getting this error
ERROR: The name cum is already defined as a variable and cannot be redeclared as an array by the ARRAY statement

Thanks so much for any help,
Frequent Contributor
Posts: 140

Re: time-varying covariates

> Hello,
>
> I am trying to look at the effect of a drug on an
> outcome. The drug was used at different intervals
> through the observation period. I set up the data as
> below
>
> NODAT Duration RAS1 RAS2 RAS3 etc for use in months
> 1, 2, 3 etc
>
> and I used this syntax
>
> proc phreg data=_proj_.imported;
> model DURATION*NODAT(0) = cum AGE / risklimits;
> array cum (*) RAS1-RAS12;
> do i = 1 to 12;
> if DURATION=i then cum=RAS; end; run;
>
> and keep getting this error
> ERROR: The name cum is already defined as a variable
> and cannot be redeclared as an array by the ARRAY
> statement
>
> Thanks so much for any help,

I think it's in the last line. You have cum = RAS, shouldn't it be cum = ras

?

But what are you trying to do here? It's not clear to me.

Peter
Valued Guide
Posts: 2,108

Re: time-varying covariates

In the MODEL statement, you have used cum as a variable. Then you have used cum as an array in the ARRAY statement. I think that you want to use ras (no subscript) in the model statement and then revers cum and ras in the IF statement.
Ask a Question
Discussion stats
  • 2 replies
  • 70 views
  • 0 likes
  • 3 in conversation