PLease help correct this, I wish to do it by replicates.
This is the code. The data set and error message is below.
CODE
proc iml;
use Complete_1;
read all var _all_ into DM;
close;
frequency =DM[,7]; y =DM[,6]; obs=DM[,10]; Censored= DM[,4]; time = DM[,3]; x =DM[,2];replicate=DM[,1];
use GIB_&p;
read all var _all_ into Col;
timeS=time;
locC=loc(censored=1); matrix=J(1,7,2.10);
do im = 1 to 1;
u = unique(Replicate);
byIdx = loc(replicate=u[im]); /* the UNIQUE-LOC trick */
byGroup = DM[byIdx,];
frequency =byGroup[,7]; y =byGroupDM[,6]; obs=byGroup[,5]; Censored= byGroup[,4]; time = byGroup[,3]; x =byGroup[,2];replicate=byGroup[,1];
do j= 1 to frequency[1];
seed=-1;
A=RANUNI(-1);
i=max(loc(Col[,j]-A>0));
if i<nrow(time) then /** do nothing if the last is censored, that is censored=1*****/
do;
timeS[locC
end;
end;
sim=repeat(im,nrow(time),1);
temp=obs||censored||time||Y||timeS||X||Sim||replicate;
Matrix=matrix//temp;
end; matrix=matrix[2:nrow(matrix),];
create impute_t_&p var{obs censored time Y timeS X replicate};
append from matrix;
quit;
ods trace on/listing;
proc sort data=impute_t_&p;
by replicate;
run;
variables:
col1=DM[,8]
frequency =DM[,7]; y =DM[,6]; obs=DM[,10]; Censored= DM[,4]; time = DM[,3]; x =DM[,2];replicate=DM[,1]
1 | 1 | 0 |
| 1 | 0 |
| 3 |
|
2 | 1 | 0 |
| 1 | 0 |
| 3 |
|
3 | 1 | 0 |
| 1 | 0 |
| 3 |
|
4 | 1 | 0 |
| 0 | 1 |
| 3 |
|
5 | 1 | 0 |
| 0 | 1 |
| 3 |
|
6 | 1 | 0 |
| 0 | 1 |
| 3 |
|
7 | 1 | 0 |
| 0 | 1 |
| 3 |
|
8 | 1 | 0 |
| 0 | 1 |
| 3 |
|
9 | 1 | 0 |
| 0 | 1 |
| 3 |
|
10 | 1 | 0 |
| 0 | 1 |
| 3 |
|
11 | 2 | 0 |
| 1 | 0 |
| 3 |
|
12 | 2 | 0 |
| 0 | 1 |
| 3 |
|
13 | 2 | 0 |
| 0 | 1 |
| 3 |
|
14 | 2 | 0 |
| 0 | 1 |
| 3 |
|
15 | 2 | 0 |
| 0 | 1 |
| 3 |
|
16 | 2 | 0 |
| 0 | 1 |
| 3 |
|
17 | 2 | 0 |
| 0 | 1 |
| 3 |
|
18 | 2 | 0 |
| 0 | 1 |
| 3 |
|
19 | 2 | 0 |
| 1 | 0 |
| 3 |
|
20 | 2 | 0 |
| 1 | 0 |
| 3 |
|
This code gives me error
NOTE: IML Ready
NOTE: Closing WORK.COMPLETE_1
ERROR: (execution) Matrices do not conform to the operation.
operation : || at line 1966 column 139
operands : obs, censored, time, Y, timeS, X, Sim, replicate
obs 10 rows 1 col (numeric)
1
1
1
1
1
1
1
0
1
1
censored 10 rows 1 col (numeric)
0
0
0
0
0
0
0
1
0
0
time 10 rows 1 col (numeric)
0.0119728
0.0119728
0.0119728
0.0000702
0.0071248
0.0071248
0.0017914
0.0079639
0.0066853
0.0066853
y 10 rows 1 col (numeric)
2.1234929
2.1234929
2.1234929
2.1003696
2.1255796
2.1255796
2.1055103
2.176416
2.1040166
2.1040166
timeS 20 rows 1 col (numeric)
X 10 rows 1 col (numeric)
0
0
0
0
0
0
1
0
0
0
sim 10 rows 1 col (numeric)
1
1
1
1
1
1
1
1
1
1
Replicate 10 rows 1 col (numeric)
1
1
1
1
1
1
1
1
1
1
The error message
timeS 20 rows 1 col (numeric)
tells you that the timeS vector is longer than the others, so you can't concatenate them together.
For more about this error message, see Interpreting PROC IML error messages: Matrices do not conform to the operation - The DO Loop
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.