## MATRIX DOES NOT CONFORM TO OPERATION, Please correct this code for me

Super Contributor
Posts: 328

# MATRIX DOES NOT CONFORM TO OPERATION, Please correct this code for me

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] = time+ (time[i+1]-time)*((Col[i,j]-A)/(Col[i,j]+col[i+1,j]));

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 0.005959 1 0 2.19394 3 8 2 1 0 0.005959 1 0 2.19394 3 7.11111 3 1 0 0.005959 1 0 2.19394 3 6.22222 4 1 0 0.006302 0 1 2.10653 3 5.33333 5 1 0 0.001931 0 1 2.10633 3 4.44444 6 1 0 0.001931 0 1 2.10633 3 3.55556 7 1 0 7.6e-05 0 1 2.09604 3 2.22222 8 1 0 0.011368 0 1 2.11672 3 1.55556 9 1 0 0.001074 0 1 2.10064 3 0.88889 10 1 0 0.001074 0 1 2.10064 3 0 11 2 0 0.005959 1 0 2.19394 3 8 12 2 0 0.01317 0 1 2.13512 3 7 13 2 0 0.006302 0 1 2.10653 3 6.5 14 2 0 0.006302 0 1 2.10653 3 6 15 2 0 0.006302 0 1 2.10653 3 5 16 2 0 0.001931 0 1 2.10633 3 4 17 2 0 0.001931 0 1 2.10633 3 2.5 18 2 0 7.6e-05 0 1 2.09604 3 1.75 19 2 0 0.005171 1 0 2.147 3 1 20 2 0 0.004562 1 0 2.12766 3 0

This code gives me error

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

SAS Super FREQ
Posts: 4,243

## Re: MATRIX DOES NOT CONFORM TO OPERATION, Please correct this code for me

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.

SAS Super FREQ
Posts: 4,243