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

sas-innovate-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 2403 views
  • 3 likes
  • 3 in conversation