Hello,
I want to write this
proc sql;
create table test as
select t1.*, t2.v
from t1 left join t2
on t1.w=t2.w;
quit;
Is there any mather , if I do not use " order by ...", an other mean, sas can give any false result ?
if we do not write
proc sql;
create table test as
select t1.*, t2.v
from t1 left join t2
on t1.w=t2.w
order by m1,
quit;
If yes, please can you give some exemples ?
The presence or lack of an "order by" statement in SQL will not affect the number of observations in the output dataset.
The above statement would be true, in a join even if you "ORDER BY" a variable that is not in the output dataset.
Even if you added something weird, like " ORDER BY monotonic(), ranuni(123) ", it should not affect the number of observations in the output dataset.
I am not sure that I understand what you mean by "false result";
Currently the implementation of proc sql without an order by variable will tend to order data by the values of the varaibles as they appear on the Select clause. The order of set T1 in your example may not be the order it had going in.
you say "Currently the implementation of proc sql without an order by variable will tend to order data by the values of the varaibles as they appear on the Select clause"
You mean that : sas will order the final data by the variables in select clause ?
Thank you
Your code works as is! The only problem might be if v and m1 are in both datasets. However, the result of either run wouldn't be false in such cases, just not what you might have expected.
It might only be a transcription typo but the comma after m1 should be a semicolon. Otherwise, proc SQL will be looking for a variable named quit.
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 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.