|
Hi...the default behavior of PROC SORT is the EQUALS option...keep
observations in their original order within the sorted BY variable(s). If
you use...
proc sort
data = one
out = three noequals;
by x ;
run ;
you get the same result in your example (and faster sorts on large files)
from PROC SORT and PROC SQL (at least in V9.1.3 on Windows XP).
Mike Zdeb
U@Albany School of Public Health
1 University Drive
Rensselaer, NY 12144-3456
(P)518-402-6479
(F)630-604-1475
toby dunn
<tobydunn@HOTMAIL
.COM> To
Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU
Discussion" cc
<SAS-L@LISTSERV.U
GA.EDU> Subject
Re: SQL Sort Different than Proc
Sort
11/09/2005 11:22
AM
Please respond to
toby dunn
<tobydunn@HOTMAIL
.COM>
T J ,
From my output window:
from sql 309
08:42 Wednesday, November 9,
2005
Obs x y
1 00001 234
2 00001 456
3 00001 345
4 00001 123
5 00002 123
6 00003 123
from proc sort 310
08:42 Wednesday, November 9,
2005
Obs x y
1 00001 123
2 00001 456
3 00001 345
4 00001 234
5 00002 123
6 00003 123
Well I guess I shouldnt have said that proc sort was ordering on X and Y
but rather should not proc sql sort and proc sort return the same results.
Toby Dunn
From: T J <tjpush@YAHOO.COM>
Reply-To: T J <tjpush@YAHOO.COM>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: SQL Sort Different than Proc Sort
Date: Wed, 9 Nov 2005 11:13:33 -0500
On Wed, 9 Nov 2005 15:50:52 +0000, toby dunn <tobydunn@HOTMAIL.COM> wrote:
>Interesting results I have found between Proc Sort and SQL Sort:
>
>
>data one ;
>infile cards ;
>input x $5. y ;
>cards ;
>00001 123
>00001 456
>00001 345
>00002 123
>00003 123
>00001 234
>;
>run ;
>
>
>proc sql ;
>create table two as
> select *
> from one
> order by x ;
>quit ;
>
>proc sort
> data = one
> out = three ;
>by x ;
>run ;
>
>proc print
>data = two ;
>run ;
>
>proc print
>data = three ;
>run ;
>
>
>
>Wonder why the SQL sort algorithm is different than proc sort. In other
>words why does Proc Sort order on x and y and proc sql sort only orders
by
X
>when I specify only to order on X .
>
>Toby Dunn
My testing shows that the proc sort result is what I expected, the y column
is not sorted, and it has retained the orig. sequence - the 1st y of a
given x appears first after x is sorted, 2nd as 2nd, and so on.
T J
|