SAS discussion board
SQL makes no guarantee on ordering. You might be seeing the results of running on multiple threads causing a change in the order.
If you really do not have a set of keys then just order on everything. You can use PROC SORT and the _ALL_ variable list. If you did have some partial keys that you want to order on add those in front of the _ALL_ keyword.
proc sort data=have;
by key1 key2 _all_;
run;
If I can echo what Tom says SQL makes no guarantee of order. In fact the SQL language was designed for relational databases and when I was taught relational database theory (many decades ago) I was told that in an RDBMS order of records should never matter.
If you're running your code against say ORACLE it's possible, as Tom says, that internally ORACLE is threading your query without you realising it.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.