BookmarkSubscribeRSS Feed
desireatem
Pyrite | Level 9

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] = 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

  1. 0.005959

1

0

  1. 2.19394

3

  1. 8.00000

2

1

0

  1. 0.005959

1

0

  1. 2.19394

3

  1. 7.11111

3

1

0

  1. 0.005959

1

0

  1. 2.19394

3

  1. 6.22222

4

1

0

  1. 0.006302

0

1

  1. 2.10653

3

  1. 5.33333

5

1

0

  1. 0.001931

0

1

  1. 2.10633

3

  1. 4.44444

6

1

0

  1. 0.001931

0

1

  1. 2.10633

3

  1. 3.55556

7

1

0

  1. 0.000076

0

1

  1. 2.09604

3

  1. 2.22222

8

1

0

  1. 0.011368

0

1

  1. 2.11672

3

  1. 1.55556

9

1

0

  1. 0.001074

0

1

  1. 2.10064

3

  1. 0.88889

10

1

0

  1. 0.001074

0

1

  1. 2.10064

3

  1. 0.00000

11

2

0

  1. 0.005959

1

0

  1. 2.19394

3

  1. 8.00000

12

2

0

  1. 0.013170

0

1

  1. 2.13512

3

  1. 7.00000

13

2

0

  1. 0.006302

0

1

  1. 2.10653

3

  1. 6.50000

14

2

0

  1. 0.006302

0

1

  1. 2.10653

3

  1. 6.00000

15

2

0

  1. 0.006302

0

1

  1. 2.10653

3

  1. 5.00000

16

2

0

  1. 0.001931

0

1

  1. 2.10633

3

  1. 4.00000

17

2

0

  1. 0.001931

0

1

  1. 2.10633

3

  1. 2.50000

18

2

0

  1. 0.000076

0

1

  1. 2.09604

3

  1. 1.75000

19

2

0

  1. 0.005171

1

0

  1. 2.14700

3

  1. 1.00000

20

2

0

  1. 0.004562

1

0

  1. 2.12766

3

  1. 0.00000

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

2 REPLIES 2
Rick_SAS
SAS Super FREQ

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-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 2 replies
  • 1205 views
  • 0 likes
  • 2 in conversation