BookmarkSubscribeRSS Feed
hagml
Calcite | Level 5

I have 60 patients, 5 cohorts where in each there are 4 female and 8 male. In each cohort the allocation ratio for female is (3:1) so 3 treatment and 1 placebo. And for male is (6:2) so 6 treatment and 2 placebo.
Cohort 1 has the 150 mg dose
Cohort 2 has 200 mg
Cohort 3 has 250 mg
Cohort 4 is "optional treatment"
Cohort 5 is "optional treatment"

I need to create a randomization code in a way that the final output looks like below:

## Cohort 1 - 150 mg ##
## Female ##

| Randomization number | Treatment |
| -------- | -------------- |
| 101 | Treatment |
| 102 | Placebo |
| 103 | Treatment |
| 104 | Treatment |

## Cohort 1 - 150 mg ##
## Female ##

| Treatment | Count |
| -------- | -------------- |
| Treatment | 3 |
| Placebo | 1 |

 

Cohort 1 - 150 mg
## Male ##

| Randomization number | Treatment |
| -------- | -------------- |
| 105 | Treatment |
| 106 | Treatment |
| 107 | Treatment |
| 108 | Placebo |
| 109 | Treatment |
| 110 | Treatment |
| 111 | Treatment |
| 112 | Placebo |
## Cohort 1 - 150 mg ##
## Male ##

| Treatment | Count |
| -------- | -------------- |
| Treatment | 6 |
| Placebo | 2 |


## Cohort 2 - 200 mg ##
## Female ##

| Randomization number | Treatment |
| -------- | -------------- |
| 201 | Treatment |
| 202 | Treatment |
| 203 | Treatment |
| 204 | Placebo |

## Cohort 2 - 200 mg ##
## Female ##

| Treatment | Count |
| -------- | -------------- |
| Treatment | 3 |
| Placebo | 1 |

 

Cohort 2 - 200 mg
## Male ##

| Randomization number | Treatment |
| -------- | -------------- |
| 205 | Placebo |
| 206 | Treatment |
| 207 | Treatment |
| 208 | Placebo |
| 209 | Treatment |
| 210 | Treatment |
| 211 | Treatment |
| 212 | Treatment |

## Cohort 2 - 200 mg ##
## Male ##

| Treatment | Count |
| -------- | -------------- |
| Treatment | 6 |
| Placebo | 2 |

.
.
.
Up to cohort 5:

## Cohort 5 - Optional dose ##
## Female ##

| Randomization number | Treatment |
| -------- | -------------- |
| 501 | Treatment |
| 502 | Treatment |
| 503 | Placebo |
| 504 | Treatment |

## Cohort 5 - Optional dose ##
## Female ##

| Treatment | Count |
| -------- | -------------- |
| Treatment | 3 |
| Placebo | 1 |

 

Cohort 5 - Optional dose
## Male ##

| Randomization number | Treatment |
| -------- | -------------- |
| 505 | Treatment |
| 506 | Treatment |
| 507 | Treatment |
| 508 | Treatment |
| 509 | Treatment |
| 510 | Treatment |
| 511 | Placebo |
| 512 | Placebo |

## Cohort 1 - Optional dose ##
## Male ##

| Treatment | Count |
| -------- | -------------- |
| Treatment | 6 |
| Placebo | 2 |

then I need to create a pdf output, an excel output and the sas output. In addition, I want a pdf output in a way that each randomization number for each male and female and the allocated treatment/placebo be printed separately on each pdf page.

I also need the same exact output but with the following randomization number (where in the title for each page, a "replacement" will be added):

Female cohort 1: 181 182 183 184
Male cohort 1: 185 186 187 188 189 190 191 192

Female cohort 2: 281 282 283 284
Male Cohort 2: 285 286 287 288 289 290 292 292

up to cohort 5:
581,...,585 (female)
585,...,592 (male)

Which I am having hard time creating them as I am not familiar with SAS programming at all. This is what I worked on so far but the problem is I could only do it for the equal number of male and female in each cohort and I cannot separate them in a way that in one pdf page I get female and the next page male (like the above output) and also having hard time creating the randomization number as above.

```
options ls=132 ps=58 nodate nonumber; title1 "RANDOMIZATION SCHEDULE"; title2 "A Randomized, Double-Blind, Placebo-Controlled, MAD Study";
%let seed=9683473;
data rannum(keep=seed);
do i=1 to 5;
rannum=ranuni(&seed);
seed=int(rannum*1000000);
output;
end; run;
proc sql noprint;
select seed
into :seed1 - :seed5
from rannum;
quit;
proc format;

value sex 1='Female'
2='Male';
value treat 1='Placebo'
2='150 mg'
3='200 mg'
4='250 mg'
5='optional dose'
6='optional dose';
run;

proc plan seed=&seed1;
factors sex=2 treat=12 /noprint;
output out=data1
sex nvals=(1 2) random
treat nvals=(1 1 1 2 2 2 2 2 2 2 2)
random;
run;
proc plan seed=&seed2;
factors sex=2 treat=12 /noprint;
output out=data2
sex nvals=(1 2) random
treat nvals=(1 1 1 3 3 3 3 3 3 3 3)
random;
run;

proc plan seed=&seed3;
factors sex=2 treat=12 /noprint;
output out=data3
sex nvals=(1 2) random
treat nvals=(1 1 14 4 4 4 4 4 4 4)
random;
run;

proc plan seed=&seed4;
factors sex=2 treat=12 /noprint;
output out=data4
sex nvals=(1 2) random
treat nvals=(1 1 1 5 5 5 5 5 5 5 5)
random;
run;

proc plan seed=&seed5;
factors sex=2 treat=12 /noprint;
output out=data5
sex nvals=(1 2) random
treat nvals=(1 1 1 6 6 6 6 6 6 6 6)
random;
run;

%macro combine(dataset);
%do i=1 %to 5;
%let dataset=data&i;
proc sort data=&dataset; by sex;
data &dataset;
set &dataset;
cohort=&i;
subid=%eval(&i.00)+(_n_);
%end; %mend;
%combine
data combine;
set data1 data2 data3 data4 data5
run;

proc sort; by cohort sex;

print data=combine noobs double
proc
uniform split='*';
var sex subid treat;
id cohort;
by cohort;
label subid="Randomization number"
treat="TREATMENT";
format treat treat.;
run;
```

1 REPLY 1
Ksharp
Super User
/*
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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 454 views
  • 0 likes
  • 2 in conversation