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. 🙂
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.