BookmarkSubscribeRSS Feed
KemarRoach
Calcite | Level 5

I have 4 datasets - A,B,C,D. Each dataset has around 500 observations. The subjects need to be scrambled within the available subject ID's. For example Actual subjects are 101,102,103,104 , they need to be scrambled as 103,101,104,102 . I am instructed to merge 4 datasets and apply scrambling for those which have subjects in dataset A. For example if dataset A has 101 as subject id and any of the datasets B,C or D has 101 as Subject id it should be scrambled with same number. Unmatched subjects should remain as it is .

Eg 1. A-101 B-101 C-101 D-101 -Actual subjects.

         A-103  B-103 C-103 D-103 - Scrambled subjects should be same across the datasets for a  particular subject.

Eg 2. A-104 B-105 C-109 D-104 - Actual subjects

         A-107 B-108 C-106 D-107 - Please observe scrambling for Dataset A and D.

Please help me with this requirement .

3 REPLIES 3
Reeza
Super User
Are all 4 files guaranteed to have the same set of IDs or will there be IDs in some data sets that are not in others? What do you mean by "not change to actual subject id"? Can you show that with a before and after data set please?

Here's an example on creating an entirely randomized IDs:
https://gist.github.com/statgeek/fd94b0b6e78815430c1340e8c19f8644
sbxkoenk
SAS Super FREQ

Agreeing with @Reeza .

 

I think this is easy to do, but the question is not 100% clear to me neither.

 

Thanks,

Koen

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

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
  • 925 views
  • 0 likes
  • 4 in conversation