SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
noda6003
Quartz | Level 8

Hi,

I want to create a dummy randomisation list to randomly assign 2 treatments for pat id's. i found many examples but if i get a new pat id then the program should randomly assign one treatment and not change the existing treatment groups. is there any existing program which does or an example would be appreciated. assigning trt A and trt B like below

pat_id       trt

101           trt A

102          trt B

103          trt B

104          trt A

 

3 REPLIES 3
Kurt_Bremser
Super User

Keep a dataset with the existing values, and randomize only the new ones:

data have;
infile cards dlm=',';
input pat_id $ trt $;
cards;
101,trt A
102,trt B
103,trt B
104,trt A
;
run;

data add;
input pat_id $;
cards;
105
;
run;

data want;
set
  have
  add
;
if trt = '' then trt = ifc(rand('normal',1) > .5,'trt A','trt B');
run;
FreelanceReinh
Jade | Level 19

@Kurt_Bremser: I think you mean the 'uniform' distribution, not the 'normal' distribution (for an allocation ratio of 1:1).

andreas_lds
Jade | Level 19

How do you get a new patient?

 

Without knowing the program you use for the initial assignment of treatments, it is hardly possible to suggest something useful, except for the most obvious: exclude the observations with non-missing trt variable when assigning trt.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 3 replies
  • 1584 views
  • 0 likes
  • 4 in conversation