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. 🙂
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.