Hi team,
I have a dataset that looks like this:
ID DIABETES CHF_FU DM_FU
1 1 21 19
2 . 10 .
3 1 19 12.
4 . 19 .
5 1 7 0
CHF_FU is the total follow-up time and DM_FU is the time that diabetes was diagnosed. I am trying to create a time-to-event data that has multiple columns per year of follow-up for diabetes. I used the following code:
proc sort data = merged;
by descending CHF_FU;
run;
data _NULL_;
set merged;
if _N_=1 then call symput('cols',CHF_FU);
run;
%put Additional Columns: &cols;
proc sort data = merged;
by ID;
run;
data merged1;
set merged;
array period[&cols];
i = 1;
do until (i > CHF_FU);
period[i] = 0;
i + 1;
end;
if not missing(DM_FU) then do j = DM_FU to CHF_FU;
period[j] = 1;
end;
drop i j;
run;
It seems to be working for the first 4 rows but generates the error message 'Array subscript out of range' when it gets to the fifth row. The fifth row belongs to an individual that has diabetes but diabetes was present at baseline (hence the DM_FU of zero).
I cannot figure out what the problem is. Any ideas?
Change line:
if not missing(DM_FU) then do j = DM_FU to CHF_FU;
into:
if DM_FU > CHF_FU then do;
put '*** Data Error: DM_FU > CHF_FU';
abort;
end;
if DM_FU>0 then do j = DM_FU to CHF_FU;
pay attention: zero is greater then missing and zero is not a vaild index;
Alternativley define an array of {&cols+1} and use index (i+1) in order
that base=0 will use index 1.
Change line:
if not missing(DM_FU) then do j = DM_FU to CHF_FU;
into:
if DM_FU > CHF_FU then do;
put '*** Data Error: DM_FU > CHF_FU';
abort;
end;
if DM_FU>0 then do j = DM_FU to CHF_FU;
pay attention: zero is greater then missing and zero is not a vaild index;
Alternativley define an array of {&cols+1} and use index (i+1) in order
that base=0 will use index 1.
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.