Thanks for your reply but I think I'm still struggling to append the data sets. I was able to save the value of the log likelihood only for the first loop. I attach the data file here and the codes I tried (without the attempt to append as it would give an error) are as follows: data data_9_3uniq;
set data_9_3;
if c=1;
run;
proc sql noprint;
select distinct t into :time from data_9_3uniq;
quit;
%macro dothis;
%do i = 1 %to %sysfunc(countw(&time));
%let thistime = %scan(&time,&i,%str( ));
ods output FitStatistics=Fit;
proc phreg data=data_9_3;
model t*c(0) = Z1 Z2 / ties=Breslow;
g_dum = g-1;
if t > &thistime then do Z2=g_dum; Z1=0; end;
else do Z2=0; Z1=g_dum; end;
run;
data outputdataset_&i;
set Fit;
time=&thistime;
keep time Criterion WithCovariates;
if Criterion="-2 LOG L";
run;
%end;
%mend;
%dothis I want to append the results from outputdataset_&i to a single file. So, the final data set will have unique times ( &thistime ) and the corresponding -2logLik or Lik.
... View more