I'm trying my hand at incorporating time-dependent variables in cox proportional hazard modeling through the counting process.
I am up to the first step - creating indicator variables to tell me when the "nlr" status changes:
ARRAY nlr_(*) nlr_0-nlr_3; *call in the time-varying nlr variables;
ARRAY chng(3); *the new indicator variables;
t=1; *initialise the position variable for the indicator variables;
DO i = 1 to 3;
if nlr_(i) NE nlr_(i-1) THEN DO; *detects whether there is a change in nlr status;
chng(t) = i-1; *assigns the last timept the status remained constant;
However, this message is popping up in my log -
ERROR: Array subscript out of range at line 2863 column 20.
This is from the change dataset:
And I am aiming for it to look like this:
Not sure what I am doing wrong - appreciate any input (sorry am a beginner at this!)
Since you iterate over 3 values, but also use i-1 to access an array element, you in fact try to access four array elements in arrays that only have three elements.
Your code needs to take care of the border cases.
Whenever an out-of-range error like this happens, you also get a list of all current variable values. Inspect that, and you'll see what happens.
The simplest change I would recommend is to change one of the array definitions. What you have now:
ARRAY nlr_(*) nlr_0-nlr_3;
What it should look like:
ARRAY nlr_ (0:3) nlr_0-nlr_3;
But for the life of me I can't figure out how you are getting values for the CHNG variables and why you want the values that you illustrate. So that question will arise once you get past the errors.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.