The PROC MEANS might yield directly what you are looking for. Look in
the online SAS help, and read about the statements maxid, minid, ...
Here is a SAS sample code for minid and maxid:
I hope it will help.
> Good morning,
> I'm in need of some urgent advice on a SAS coding problem. I am trying
> to locate the highest/lowest price (and associated event time) that
> existed during the lifespan of an order. This is determined by
> comparing the price of the order to those that occurred during the life
> of the order and is done separately for two types of orders.
> Consider the following event dataset:
> Ohecode Time ohebs lo_price B1pr S1pr
> DGAE709 08:07:48 B 122.50 122.50 123.00
> TANA05T 08:07:50 B 121.50 122.50 123.00
> SGTIA05T 08:07:52 S 122.75 123.50 123.75
> GJCXEUT 08:07:55 B 122.00 121.00 121.50
> DGAE709 08:08:00 B 122.50 122.75 123.00
> SGTIA05T 08:08:10 S 122.75 121.75 122.00
> GUOLS5T 08:08:15 S 123.00 122.75 123.00
> TANA05T 08:09:50 B 121.50 122.75 123.00
> I seek the following solution:
> Ohecode Time Best_price Event_time
> GJCXEUT 08:07:55 122.00 08:07:55
> DGAE709 08:08:00 123.50 08:07:52
> SGTIA05T 08:08:10 121.50 08:07:55
> GUOLS5T 08:08:15 123.00 08:08:15
> TANA05T 08:09:50 123.50 08:07:52
> Please note that the "best_price" for each order is derived as
> If ohebs = 'B' then best_price (and associated event_time) for the
> particular order is:
> First.time LE max(lo_price, B1pr) LE last.time.
> Else if ohebs = 'S' then best_price (and associated event_time) for
> the particular order is:
> First.time LE min(lo_price, S1pr) LE last.time.
> Thanks for the assistance.
> Take care.