Hi There, what is wrong with this code?
proc iml;
use kaplan;
read all var{monset Survival survival1} into DM; 
close;
Survival1 = DM[,3]; Survival = DM[,2]; monset = DM[,1];                                                              /*Survivalival is second column*/  /*monset is first column*/
n = nrow(DM);                                                                              /*number of rows in the dataset = obs*/ /*THE N DOESNT NEED TO BE FIXED*/
segment = J(nrow(DM),1,1); *print segment; 
do i = 2 to nrow(DM);
if monset=monset[i+1] then survival1=survival1[i+1];
if monset[i-1]=monset then survival1[i-1]=survival1;
if monset=monset[i-1] then survival1=survival1[i-1];
end;
create Mkaplan var{monset Survival survival1};
append;
quit;
ERROR: (execution) Invalid subscript or subscript out of range.
 operation : [ at line 872 column 20
 operands  : monset, _TEM1002
MONSET    141 rows      1 col     (numeric)
_TEM1002      1 row       1 col     (numeric)
       142