Date: Fri, 1 Jul 2005 13:43:55 -0400
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject: Re: question about selecting lowest value with similar ID
variables using proc sql
Have you thought about, and tested, the situation where there is a tie? For
example:
ID X Y
1 3 3
1 1 1
1 4 2
1 3 2
2 4 5
2 5 4
2 6 3
2 9 3 <--- tie for min. Y but different X
On Fri, 1 Jul 2005 09:07:55 -0700, m k <odshtml@YAHOO.COM> wrote:
>Works A+
>
>Thanks
>MK
>
>Eric Yount <eric.yount@rtp.ppdi.com> wrote:
>Hi m k,
>
>Try this (tested):
>
>proc sql;
>create table B as
>select *
>from A
>group by ID
>having min(Y) = Y;
>quit;
>
>Hope this helps,
>Eric
>
>
>m k wrote:
>> Hi
>>
>> I have a table A with these values
>>
>> ID X Y
>> 1 3 3
>> 1 1 1
>> 1 4 2
>> 1 3 2
>> 2 4 5
>> 2 5 4
>> 2 6 3
>>
>> Now, I want to create B from A with smallest Y for each ID
>> which would look like this
>>
>> ID X Y
>> 1 1 1
>> 2 6 3
>>
>> I tried this with proc sql
>>
>> proc sql;
>> create table B as select distinct ID, X, min(Y)
>> from A group by ID ;
>> quit;
>>
>> but I'm not getting the proper output.
>>
>> Am I doing it right?
>>
>>
>>
>> MANY Thanks as always
>>
>> MK
>>
>>
>> ---------------------------------
>> Yahoo! Sports
>> Rekindle the Rivalries. Sign up for Fantasy Football
>>
>
>
>______________________________________________________________________
>This email transmission and any documents, files or previous email
>messages attached to it may contain information that is confidential or
>legally privileged. If you are not the intended recipient or a person
>responsible for delivering this transmission to the intended recipient,
>you are hereby notified that you must not read this transmission and
>that any disclosure, copying, printing, distribution or use of this
>transmission is strictly prohibited. If you have received this transmission
>in error, please immediately notify the sender by telephone or return email
>and delete the original transmission and its attachments without reading
>or saving in any manner.
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam? Yahoo! Mail has the best spam protection around
>http://mail.yahoo.com
|