@FreelanceReinh can you please help me with this
The dataset is below
data ndsn;
infile datalines;
input subjid study site usubjid $15.;
datalines;
120 303 100 303-100-120
121 303 100 303-100-121
122 303 101 303-101-122
123 303 101 303-101-123
124 303 102 303-102-124
125 303 102 303-102-125
126 303 103 303-103-126
127 303 103 303-103-127
128 303 104 303-104-128
129 303 104 303-104-129
;
run;
and i have got 3 datasets where i need to blind only the subjects those were having a specific condition, for example CM dataset has a variable called CMANG and if CMANG =Yes only then i need to scramble or else the rest of the subjects should remain same without any scrambling. Client is having this requirement only for 3 datasets and the rest of the datasets will be scrambled as per earlier solution you had provided.
Thanks a lot for your help.
Have you tried the suggestion I made yesterday in the previous thread for exactly this type of data? In short: split -- scramble -- interleave.
In detail:
/* Split */
data cm_yes cm_rest;
set ndsn;
if cmang='Yes' then output cm_yes;
else output cm_rest;
run;
/* Scramble */
proc surveyselect data=cm_yes(keep=usubjid) seed=5772 noprint
out=cm_yes_scrm_id(keep=usubjid) samprate=1 outrandom;
run;
data cm_yes1;
merge cm_yes(drop=usubjid) cm_yes_scrm_id;
run;
/* Interleave */
data want;
set cm_yes1 cm_rest;
by study site subjid;
run;
What does scramble mean? Please be specific.
When you say scramble, do you mean randomly assign a number starting with 1?
Please post data matching your description. You are mentioning the variable cmang, but it is not in the dataset you have posted.
The modified data including CMANG variable as below
data ndsn;
infile datalines;
input subjid study site cmang $3. usubjid $15.;
datalines;
120 303 100 Yes 303-100-120
121 303 100 No 303-100-121
122 303 101 Yes 303-101-122
123 303 101 No 303-101-123
124 303 102 No 303-102-124
125 303 102 No 303-102-125
126 303 103 Yes 303-103-126
127 303 103 No 303-103-127
128 303 104 No 303-104-128
129 303 104 No 303-104-129
;
run;
When the variable CMANG=Yes only then they need to get scrambled
Have you tried the suggestion I made yesterday in the previous thread for exactly this type of data? In short: split -- scramble -- interleave.
In detail:
/* Split */
data cm_yes cm_rest;
set ndsn;
if cmang='Yes' then output cm_yes;
else output cm_rest;
run;
/* Scramble */
proc surveyselect data=cm_yes(keep=usubjid) seed=5772 noprint
out=cm_yes_scrm_id(keep=usubjid) samprate=1 outrandom;
run;
data cm_yes1;
merge cm_yes(drop=usubjid) cm_yes_scrm_id;
run;
/* Interleave */
data want;
set cm_yes1 cm_rest;
by study site subjid;
run;
@FreelanceReinh I had tried that yesterday and its working now. Thanks a lot for this solution. I am able to send the reports on time.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.