Statistical programming, matrix languages, and more

ERROR: (execution) Invalid subscript or subscript out of range.

Accepted Solution Solved
Reply
Super Contributor
Posts: 271
Accepted Solution

ERROR: (execution) Invalid subscript or subscript out of range.

Please, How do I fix this;

proc iml;

     use Complete;

    read all var _all_ into DM;    

      close;

    frequency =DM[,5]; y =DM[,4]; status=DM[,3]; Censored= DM[,2]; time = DM[,1];

      use GIB;

    read all var _all_ into Col;   

timeS=time;

locC=loc(censored=1); matrix=J(1,6,-99);

do im=1 to 25;

do j= 1 to frequency[1];

   A=RANUNI(-1);

   i=max(loc(Col[,j]-A>0));

   timeS[locC] = time+ (time[i+1]-time)*((Col[i,j]-A)/(Col[i,j]+col[i+1,j]));

end;  sim=repeat(im,nrow(time),1);

temp=status||censored||time||Y||timeS||sim;

Matrix=matrix//temp;

end; matrix=matrix[2:nrow(matrix),];

create impute_t var{status censored time Y timeS sim};

      append from matrix;

quit;

843  proc iml;

NOTE: IML Ready

844       use Complete;

845      read all var _all_ into DM;

846        close;

NOTE: Closing WORK.COMPLETE

847      frequency =DM[,5];

847!                        y =DM[,4];

847! status=DM[,3];

847! Censored= DM[,2];

847! time = DM[,1];

848        use GIB;

849      read all var _all_ into Col;

850  timeS=time;

851  locC=loc(censored=1);

851!                       matrix=J(1,6,-99);

852  do im=1 to 25;

853

854  do j= 1 to frequency[1];

855     A=RANUNI(-1);

856     i=max(loc(Col[,j]-A>0));

857     timeS[locC] = time+ (time[i+1]-time)*((Col[i,j]-A)/(Col[i,j]+col[i+1,j]));

858  end;

858!       sim=repeat(im,nrow(time),1);

859  temp=status||censored||time||Y||timeS||sim;

860  Matrix=matrix//temp;

861  end;

ERROR: (execution) Invalid subscript or subscript out of range.

operation : [ at line 857 column 35


Accepted Solutions
Solution
‎02-07-2013 03:50 PM
SAS Employee
Posts: 94

Re: ERROR: (execution) Invalid subscript or subscript out of range.

From your error message, in the statement;

857     timeS[locC] = time+ (time[i+1]-time)*((Col[i,j]-A)/(Col[i,j]+col[i+1,j]));

the subscript in time[i+1] exceeds the dimension of time vector. This would happend if col[i,j] > A for some i >= the number of rows in time. You can add some print statements in the loop to see exactly what is happening, and then you will need to figure out how to handle that case, if it is legitimate.

View solution in original post


All Replies
Solution
‎02-07-2013 03:50 PM
SAS Employee
Posts: 94

Re: ERROR: (execution) Invalid subscript or subscript out of range.

From your error message, in the statement;

857     timeS[locC] = time+ (time[i+1]-time)*((Col[i,j]-A)/(Col[i,j]+col[i+1,j]));

the subscript in time[i+1] exceeds the dimension of time vector. This would happend if col[i,j] > A for some i >= the number of rows in time. You can add some print statements in the loop to see exactly what is happening, and then you will need to figure out how to handle that case, if it is legitimate.

Post a Question
Discussion Stats
  • 1 reply
  • 1541 views
  • 1 like
  • 2 in conversation