Please, I need help with this code;
proc iml;
use Complete;
read all var _all_ into DM;
close;
pibflr =DM[,1]; monset= DM[,2]; censored=DM[,3]; frequency =DM[,4];
use GIB;
read all var _all_ into Col;
monsetS=monset;
locC=loc(censored=1); matrix=J(1,5,2.5);
do im=1 to 141;
do j= 1 to frequency[1];
seed=-1;
A=RANUNI(-1);
i=max(loc(Col[,j]-A>0));
if i<nrow(monset) then /** do nothing if the last is censored, that is censored=1*****/
do;
monsetS[locC
end;
end;
sim=repeat(im,nrow(monset),1);
temp=pibflr||monset||censored||monsetS||sim;
Matrix=matrix//temp;
end; matrix=matrix[2:nrow(matrix),];
create impute_t var{ censored pibflr monset monsetS sim};
append from matrix;
quit;
ods trace on/listing;
NOTE: "C:\Users\foa577\Desktop\complete.csv" file was successfully created.
1502 proc iml;
NOTE: IML Ready
1503 use Complete;
1504 read all var _all_ into DM;
1505 close;
NOTE: Closing WORK.COMPLETE
1506 pibflr =DM[,1];
1506! monset= DM[,2];
1506! censored=DM[,3];
1506! frequency =DM[,4];
1507 use GIB;
1508 read all var _all_ into Col;
1509 monsetS=monset;
1510 locC=loc(censored=1);
1510! matrix=J(1,5,2.5);
1511 do im=1 to 141;
1512 do j= 1 to frequency[1];
1513 seed=-1;
1514 A=RANUNI(-1);
1515 i=max(loc(Col[,j]-A>0));
1516 if i<nrow(monset) then /** do nothing if the last is censored, that is
1516! censored=1*****/
1517 do;
1518 monsetS[locC
1518! (monset[i+1]-monset[i-1])*((Col[i-1,j]-A)/(Col[i-1,j]-col[i+1,j]));
1519 end;
1520 end;
1521 sim=repeat(im,nrow(monset),1);
1522 temp=pibflr||monset||censored||monsetS||sim;
1523 Matrix=matrix//temp;
1524 end;
ERROR: (execution) Invalid subscript or subscript out of range.
operation : [ at line 1515 column 19
operands : Col, , j
Col 141 rows 125 cols (numeric)
j 1 row 1 col (numeric)
126
statement : ASSIGN at line 1515 column 6
1524! matrix=matrix[2:nrow(matrix),];
ERROR: (execution) Invalid subscript or subscript out of range.
operation : [ at line 1524 column 19
operands : matrix, *LIT1023, _TEM1001,
matrix 1 row 5 cols (numeric)
2.5 2.5 2.5 2.5 2.5
*LIT1023 1 row 1 col (numeric)
2
_TEM1001 1 row 1 col (numeric)
1
statement : ASSIGN at line 1524 column 6
1525 create impute_t var{ censored pibflr monset monsetS sim};
1526 append from matrix;
1527 quit;
NOTE: Exiting IML.
NOTE: The data set WORK.IMPUTE_T has 1 observations and 5 variables.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IML used (Total process time):
real time 0.08 seconds
cpu time 0.06 seconds
1528 ods trace on/listing;
The error says that COL has 125 columns. The value of j is 126. Thus the subscript Col[ ,j] is invalid.
The error says that COL has 125 columns. The value of j is 126. Thus the subscript Col[ ,j] is invalid.
Thanks for the help
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.