/*
You are asking too much questions.
I have no time to follow all your questions.
The following code could give you a start
*/
proc plan seed=123 ;
factors cohorts=5 ordered subject=4 random/noprint;
treatments treat=4;
output out=female;
run;
factors cohorts=5 ordered subject=8 random/noprint;
treatments treat=8;
output out=male;
run;
quit;
data female;
set female;
length sex treatment $ 20;
sex='female';
treatment=ifc(treat in (1:3),'treatment ','placebo');
run;
data male;
set male;
length sex treatment $ 20;
sex='male';
treatment=ifc(treat in (1:6),'treatment ','placebo');
run;
proc format;
value fmt
1='150 mg'
2='200 mg'
3='250 mg'
4='optional treatment'
5='optional treatment2'
;
run;
data want;
set female male(in=inb);
by cohorts;
subjectid=100*cohorts+subject+ifn(inb,4,0);
format cohorts fmt.;
label subjectid='Randomization number' treatment='Treatment';
run;
%macro print(sex=,cohorts=);
title "##Cohort: %cmpres(%sysfunc(putn(&cohorts.,fmt.)))##";
title2 "## &sex. ##";
proc report data=want nowd;
where upcase(sex)="%upcase(&sex.)" and cohorts=&cohorts.;
column subjectid treatment ;
define subjectid/order;
run;
proc sql;
select treatment,count(*) as Count from want where upcase(sex)="%upcase(&sex.)" and cohorts=&cohorts. group by treatment;
quit;
%mend;
options nodate nonumber;
ods pdf file='c:\temp\want.pdf' style=journal startpage=no;
%print(sex=female,cohorts=1)
ods pdf startpage=now;
%print(sex=female,cohorts=2)
ods pdf startpage=now;
%print(sex=female,cohorts=3)
ods pdf startpage=now;
%print(sex=female,cohorts=4)
ods pdf startpage=now;
%print(sex=female,cohorts=5)
ods pdf startpage=now;
%print(sex=male,cohorts=1)
ods pdf startpage=now;
%print(sex=male,cohorts=2)
ods pdf startpage=now;
%print(sex=male,cohorts=3)
ods pdf startpage=now;
%print(sex=male,cohorts=4)
ods pdf startpage=now;
%print(sex=male,cohorts=5)
ods pdf close;
... View more