LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2002, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 28 Aug 2002 11:46:58 -0400
Reply-To:   Howard_Schreier@ITA.DOC.GOV
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Howard_Schreier@ITA.DOC.GOV
Subject:   Re: How to find MAX value corresponding with time.

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


Back to: Top of message | Previous page | Main SAS-L page