BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
desireatem
Pyrite | Level 9

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

1 ACCEPTED SOLUTION

Accepted Solutions
Hutch_sas
SAS Employee

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

1 REPLY 1
Hutch_sas
SAS Employee

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 1 reply
  • 3596 views
  • 1 like
  • 2 in conversation