I need to jumble my observations. Like if I have following:
1
2
3
4
5
6
.
Then I need any jumbled list like:
5
3
6
1
4
2
.
Any easy idea?
Any code to randomize the order in which observations are in data will be of great help.
Thanks a lot!
Check the RAND() function if you have SAS9.4M4 or Later
DATA TEST;
input num;
random_num=RAND("NORMAL");
datalines;
1
2
3
4
5
;
run;
PROC SORT DATA=Test;
by random_num;
run;
This smacks of an XY Problem. Perhaps you could tell us what you are trying to do in a larger context?
In the immediate: You could generate a random number for each observation and then sort by the random number.
PROC SURVEYSELECT, no replacement.
https://gist.github.com/statgeek/8a9e15cd823aaf7b54c2d5b1bc6faab1
Check the RAND() function if you have SAS9.4M4 or Later
DATA TEST;
input num;
random_num=RAND("NORMAL");
datalines;
1
2
3
4
5
;
run;
PROC SORT DATA=Test;
by random_num;
run;
You should just look at me, and do whatever I do. My observations are always jumbled. At least that's what my wife tells me.
But does she tell you you have an XY Problem? 🙂
@HB wrote:
But does she tell you you have an XY Problem? 🙂
Probably just the pesky XY chromosome pairing. 🙂
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.