DATA Step, Macro, Functions and more

how to set the seed in random number generation in SQL

Reply
Super Contributor
Posts: 298

how to set the seed in random number generation in SQL

Hello,

 

Im in doubt of how to set the seed when using the rand() function in proc sql. Im aware that the "call streaminit" routine can be used if one will use the rand function in datasteps. How do I do it in proc sql? Or alternatively in fedsql?

 

As example, lets say that I want to order the dataset "mydata" in a random order.

 

data mydata;
  do i=1 to 20;
  output;
  end;
run;
proc sql;
  select * from mydata
  order by rand('uniform');
quit;

PROC Star
Posts: 7,490

Re: how to set the seed in random number generation in SQL

Posted in reply to JacobSimonsen

I don't think you can set the seed, using the rand function in proc sql. It will automatically use the system clock. If you want to use a specific seed, you'd either have to use the ranuni function or run it in a data step where you can set a specific seed.

 

Art, CEO, AnalystFinder.com

 

Ask a Question
Discussion stats
  • 1 reply
  • 154 views
  • 0 likes
  • 2 in conversation