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 (January 2010, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 15 Jan 2010 21:28:35 -0500
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: SUM by Time Stamp
Comments: To: OR Stats <stats112@GMAIL.COM>

I think you can get what you want with someting like:

data have; retain start; informat datetime anydtdtm.; input datetime x y; if _n_ eq 1 then start=datetime; interval=intck('minute10',start,datetime); cards; jan-15-10:00:01:30 1 1 jan-15-10:00:02:30 1 1 jan-15-10:00:03:30 1 1 jan-15-10:00:04:30 1 1 jan-15-10:00:09:55 4 4 jan-15-10:00:10:05 5 5 jan-15-10:00:19:05 6 6 jan-15-10:00:20:05 7 7 ;

data want; set have; by interval; retain finaly_start; if first.interval then do; finalx=x; finaly_start=y; end; else finalx+x; if last.interval then do; finaly_end=y; output; end; run;

HTH, Art ------- On Fri, 15 Jan 2010 19:37:33 -0600, OR Stats <stats112@GMAIL.COM> wrote:

>Hello: > >I have data > >T X Y > >where T is the date-hour-min-seconds ; X is some #; and Y is some #. >Everyday, for every 10 minutes, I want to find the sum of X, and save the >first and last value of Y. How do I do this in SAS? > >For example, my data may begin on january 15, 2010 at 1.5 minutes past >midnight. > >jan-15-10: 00: 01: 30 x1 y1 >. >. >. >jan-15-10: 00: 09: 55 x4 y4 >jan-15-10: 00: 10: 05 x5 y5 >jan-15-10: 00: 19: 05 x6 y6 >jan-15-10: 00: 20: 05 x7 y7 >. >In the above, I would like the output for the first 10 minutes to be >first row of output (when time is first 10minutes) >finalx=x1+...+x4 >finaly_start=y1 >finaly_end=y4 > >and this repeats for the next 10 minutes. Notice that at 10min & 5sec past >midnight is not included in the first 10 minutes, but in the second 10 >minutes in the next row of the output >second row of output (when 10min<time<=20minutes) >finalx=x5+x6 >finaly_start=y4 >finaly_end=y6 > >Thx much!


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