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. 🙂
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.