Hello Rick, I have modified my code as you said. This is the code, but it does not creat GIB. I do not know the dimension so I do not know how to set a default matrix; proc iml; use KMM_&p; read all var{time censored survival1 frequency y replicate } into DM; /*read the 3 variables into matrix*/ /*have to print within DM*/ close; /*close the link between the dataset and IML*/ replicate=DM[,6]; y=DM[,5];frequency =DM[,4]; survival1 =DM[,3]; Censored= DM[,2]; time = DM[,1]; /*Survivalival is second column*/ /*time is first column*/ n = nrow(DM); /*number of rows in the dataset = obs*/ /*THE N DOESNT NEED TO BE FIXED*/ /*Segment equals the number of consecutive patterns*/ /*J creates a matrix in IML , it creates a 100x1 matrix of 1s, the 3rd 1 is the value in matrix*/ segment = J(nrow(DM),1,1); *print segment; do k = 1 to ncol(u); byIdx = loc(replicate=u ); /* the UNIQUE-LOC trick */ byGroup = DM[idx,]; y=byGroup[,5];freqency =byGroup[,4]; survival1 =byGroup[,3]; Censored= byGroupDM[,2]; time = timeDM[,1]; do i = 2 to nrow(DM); if ((Censored=1)=(Censored[i-1]=1)) then segment=segment[i-1]; /**/ /* coming up with unique segments for censored*****/; else if ((Censored=1)=1-(Censored[i-1]=1)) then segment=segment[i-1]+1; *print time survival1 censored frequency segment; *print segment; end; SurvivalM=J(nrow(survival1),1,1); do i = 1 to n; if censored=1 then SurvivalM=survival1; else if censored=0 then SurvivalM=survival1; /*****Create a 1 by N -matrix of Survival ****/; end; *print SurvivalM; InverseC=J(nrow(survival1),1,1); do i = 1 to n; if censored=1 then InverseC=1/survival1; else if censored=0 then InverseC=0; /*****survivalC is the imputed censored survival and set the real Survivalval to 1**/; end; do i = 1 to ncol(frequency); call symputx("j", i); m = num(symget("j")); m=1*m; print m; %let mm=m; end; t=InverseC[(loc(InverseC^=0))]; print t; tt=t(t); print tt; Big=SurvivalM*(tt); end; create GIB_&p from BIG[colname={COL1}]; append from BIG; quit; LOCK FILE NOTE: IML Ready NOTE: Closing WORK.KMM_1 ERROR: Matrix Big has not been set to a value. statement : CREATE at line 913 column 93 ERROR: No data set is currently open for output. statement : APPEND at line 913 column 133 NOTE: Exiting IML. NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE IML used (Total process time): real time 0.00 seconds cpu time 0.01 seconds
... View more