|
I don't think I've seen this one (tested):
select * from
(select * from table1
group by county
having value=max(value))
group by county
having valuetime=min(valuetime);
On Mon, 26 Aug 2002 14:08:31 -0700, AT <tangtk@COLUMB31.DHEC.STATE.SC.US>
wrote:
>I have this dataset:
>
>data Table1;
>format ValueTime time8.;
>infile cards;
>input County $ ValueTime time8. value;
>cards;
>Alpha 12:00:00 10
>Alpha 12:01:00 15
>Alpha 12:02:00 15
>Beta 12:00:00 17
>Beta 12:01:00 6
>Beta 12:02:00 12
>;
>run;
>
>I would like to have a query that returns the County, maximum value
>and
>the first time that value occurred
>
>County MaxValue MinValueTime
>------------------------------------
>Alpha 15 12:01:00
>Beta 17 12:00:00
>.
>.
>
>So far I have this and the query returns every date/time for a given
>County where the Value happens to be the maximum, when all I want is
>the first one.
>
>proc sql noprint;
>create table max as
>SELECT County, max(Value) as MaxValue, ValueTime
>from table1
>group by County;
>quit;
>run;
>
>If there is a better way to work this out, PLMK. Any respones would
>be appreicated.
>
>Allie
|