Date: Wed, 5 Nov 2003 10:48:24 -0500 "Richard A. DeVenezia" "SAS(r) Discussion" "Richard A. DeVenezia" Re: Help? Pick up the every first record in 5 minutes intervals every day.

"Robert" <deps_bear@yahoo.com> wrote in message news:684bfca2.0311050702.76872a07@posting.google.com... > Non-SQL approach: > > data temp; > set first_obs; > timea = put(rawtime,z6.); > time = hms(substr(timea,1,2),substr(timea,3,2),substr(timea,5,2)); > format date1 date9. time time8.; > run; > > proc sort;by date1 time; > > data temp; > retain basetime; > set temp; > by date1 time; > if first.date1 then basetime=time; > diff = floor ( ( abs( (basetime - time) / 60 ) ) / 5 ) ; > format basetime time8.; > run; > > proc sort;by date1 time diff; > > data temp; > set temp; > by date1 diff time ; > if first.diff; > keep date1 time price; > run; > > proc print; > var date1 time price;

... and NON-SQL single pass, presuming sorted CARDS data...

DATA ticker; format datetime datetime16.;

retain next5_at .;

INPUT date yymmdd8. +4 h 2. m 2. s 2. price; datetime = dhms (date,h,m,s);

if datetime >= next5_at;

next5_at = floor (datetime/300) * 300 + 300;

drop date h m s next5_at; CARDS; 20010903 084501 4452.00 20010903 084503 217.90 20010903 084506 645.00 20010903 084509 4452.00 20010903 084511 4450.00 20010903 085002 4479.00 20010903 085006 647.00 20010903 085009 4478.00 20010903 085011 4479.00 20010903 085013 219.40 20010903 085503 219.10 20010903 085506 646.00 20010903 085511 4479.00 20010903 085513 219.10 20010903 085516 645.00 20010904 084501 4378.00 20010904 084503 4385.00 20010904 084508 639.00 20010904 084511 4380.00 20010904 084521 4380.00 20010904 085003 4390.00 20010904 085007 4390.00 20010904 085011 4389.00 20010904 085013 4390.00 20010904 085018 638.20 ; RUN;