BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
spirto
Quartz | Level 8

hi all,

im not sure where to post this so ill start here.

i want to create an incomplete block design. i have 8 treatments A-H. i need to create 3 blocks of size 2.

now here is where im getting it stuck. there are treatment pairs that cannot be separated. in other words, A/B need to stay together, C/D, E/F, and G/H. so out of those four pairs i need to pick 3 pairs and i have to replicate this 50 times. i need all the pairs to be distributed equally and uniformly.

so for example replicate 1 may look like

Block 1Block 2Block 3
AEC
BFD

replicate 2 would may like

Block 1Block 2Block 3
EAC
FBD

any thoughts???

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

Since you haven't stated clearly if the order of treatments matters, so here is the combination version of the code. If it does matter, then use permutation version of it.

data _null_;

   array x(4) $2  ('AB' 'CD' 'EF' 'GH');

   seed = 1234567890123;

   do n=1 to 50;

      call rancomb(seed, 3, of x1-x4);

      put seed= @20 ' x= ' x1-x3;

   end;

run;

Haikuo

View solution in original post

4 REPLIES 4
data_null__
Jade | Level 19

If the pairs can't be separated doesn't that mean you really only have 4 "treatments"?

Haikuo
Onyx | Level 15

Since you haven't stated clearly if the order of treatments matters, so here is the combination version of the code. If it does matter, then use permutation version of it.

data _null_;

   array x(4) $2  ('AB' 'CD' 'EF' 'GH');

   seed = 1234567890123;

   do n=1 to 50;

      call rancomb(seed, 3, of x1-x4);

      put seed= @20 ' x= ' x1-x3;

   end;

run;

Haikuo

SteveDenham
Jade | Level 19

Thanks !  This was the perfect code reminder for a completely separate place and project--I had forgotten about rancomb and ranperm, and PROC PLAN was driving me nuts.

Steve Denham

Rick_SAS
SAS Super FREQ

Not only random permutations, but also ordered sets of permutations:

http://blogs.sas.com/content/iml/2010/10/13/generate-all-permutations-in-sas/

By the way,  in SAS/IML software the ALLCOMB, ALLPERM, RANCOMB, and RANPERM functions work on arbitrary sets, not just integers 1:n.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 2076 views
  • 3 likes
  • 5 in conversation