BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
alan0101
Obsidian | Level 7

Hi

I have a dataset with 10 variables and 600k records.  It is the end result of a number of preceding processes, and one of the effects of these processes is that the dataset is ordered by age.  Is there a simple sas procedure which can be written to get rid of the sorting ?  I don't want to do say 3 proc surveyselects and then put the datasets together again

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

This will order your data randomly:

data want;

  set have;

  scramble_var = ranuni(0);

run;

proc sort data = want;

  by scramble_var;

run;

View solution in original post

4 REPLIES 4
SASKiwi
PROC Star

This will order your data randomly:

data want;

  set have;

  scramble_var = ranuni(0);

run;

proc sort data = want;

  by scramble_var;

run;

alan0101
Obsidian | Level 7

Great thanks SASKiwi !

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

Just for laughs, try proc whisk?

For the above, you could do in one step:

proc sql;

  create table want as select * from sashelp.cars order by ranuni(0);

quit;

Also, I would ask why do you want to scramble the dataset.  Generally ordered datasets would be easier to use, maybe you just need to change the order or retain original ordering:

data original;

     set original;

     ord=_n_;

run;

Then later on sort by _n_ to get it to the original sort.

alan0101
Obsidian | Level 7

Also great thanks RW 9 !  I want to scramble the datasets so that the customers are not called in any predefined sequence or bias which is built in via the preceding datasteps

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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
  • 4 replies
  • 5229 views
  • 3 likes
  • 3 in conversation