/*The PERM_GEN macro code appears on page 103 in the book, "SAS(R) Survival Analysis Techniques for Medical Research, Second Edition" by Alan B. Cantor, Ph.D. */ %macro perm_gen(indata = &syslast, time = , cens = , n1 = , n2 = , group =); %let n = %eval(&n1 + &n2); %let ncomb = %sysfunc(comb(&n, &n1)); ods output Plan=Combinations; proc plan ; factors replicate= &ncomb ordered r= &n1 of &n comb; run; data reps; set combinations; keep replicate i &group ; array r{*} r1 - r&n1; array grp{*} group1 - group&n; do i = 1 to &n; grp{i} = 2; do j = 1 to &n1; if r{j} = i then grp{i} = 1; end; &group = grp{i}; output; end; run; data temp; set _null_; %do i = 1 %to &ncomb; data temp; set temp &indata; keep &time &cens; %end; data reps; merge reps temp; data temp2; set &indata; replicate = 0; data reps; set temp2 reps; run; %mend;