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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.