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

@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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

@Ravindra_:

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;

View solution in original post

7 REPLIES 7
japelin
Rhodochrosite | Level 12

What does scramble mean? Please be specific.

Ravindra_
Quartz | Level 8
I have a dataset with almost more than 1000 subjects and they have subjid in the format of 303-101-120, 303-100-130, 303-103-140........ I need to scramble the subject id, i.e i need to assign a subejct id from one record to other record and so on but i should not make any modification to the subject id for example: 1,2,3,4,5 are subject id's and these need to assigned as 3,5,1,4,2. here we are not making any modification but just scrambling subject id. For few datasets i only need to scramble those subjects that were having a specific condition like CMANG=yes... hope this clarifies.
japelin
Rhodochrosite | Level 12

When you say scramble, do you mean randomly assign a number starting with 1?

andreas_lds
Jade | Level 19

Please post data matching your description. You are mentioning the variable cmang, but it is not in the dataset you have posted.

Ravindra_
Quartz | Level 8

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

FreelanceReinh
Jade | Level 19

@Ravindra_:

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;
Ravindra_
Quartz | Level 8

@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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 7 replies
  • 1191 views
  • 1 like
  • 4 in conversation