| Date: | Wed, 22 Apr 1998 09:49:43 -0600 |
| Reply-To: | Jack Hamilton <jack_hamilton@HCCOMPARE.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU> |
| From: | Jack Hamilton <jack_hamilton@HCCOMPARE.COM> |
| Subject: | Re: Copy PROC SORT options in SQL |
|
| Content-Type: | text/plain; charset=US-ASCII |
Randy Childs <rchild@ABTI.COM> wrote:
>Can anyone in the group tell me if it is possible to accomplish the
>same task performed by this one PROC SORT in one or two PROC SQL
>statements?
Your message seems to have gone through MIME encoding somewhere along
the way. Please turn it off, as it makes the message difficult to read.
I changed the dataset names in your example below; I couldn't easily tell
what they because they became encoded.
>PROC SORT DATA=IN OUT=OUT (KEEP = PATID STOP_SD) NODUPKEY;
> BY PATID DESCENDING STOP_SD;
> WHERE OUTCOME = 4;
>RUN;
Untested code:
proc sql;
create table out as
select distinct
patid,
stop_sd
from in
where outcome=4
order patid,
stop_sd desc;
In the case where the sort vars are not the same as the keep vars,
neither my SQL code nor your PROC SORT code will always function as
desired (see SAS Usage Note V6-SORT-B272); a combination of a sort and a
data step is probably the best solution.
|