BookmarkSubscribeRSS Feed
keherder
Obsidian | Level 7

Hello! I am wondering if anyone has an answer on how I can randomize the order of one variable within strata. So, I used proc plan to create 3 randomization lists stratified by clinic and cancer stage (10 strata) in blocks of 2, 4, and 8. I merged the 3 lists into 1, but now within each strata, the blocks are ordered by all the blocks of 2, all the blocks of 4, and all the blocks of 8. I somehow want to randomize the order of the blocks within each strata. Can anyone help me with this? Each block has its own number, so I can see that they are ordered chronologically. Thank you!

2 REPLIES 2
keherder
Obsidian | Level 7
To clarify, I do not simply want to randomize the order of observation within the strata, but I want to RETAIN the order of the blocks and randomize their order within each strata. Each block has an identifying number. Thank you!
andreas_lds
Jade | Level 19

Posting data as working data step will, most likely, increase quantity and quality of the answer given by the community.

So this is untested code:

data ordered;
  set have;
  new_position = rand('uniform');
run;

proc sort data=ordered out=want;
  by identifying_number new_position;
run;
  
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 833 views
  • 0 likes
  • 2 in conversation