Date: Thu, 3 Jan 2008 17:08:24 -0500
Reply-To: Mike Rhoads <RHOADSM1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mike Rhoads <RHOADSM1@WESTAT.COM>
Subject: Re: creating 1 hour averages
In-Reply-To: <3b8837c0-12db-4191-af74-d7cb22665143@l1g2000hsa.googlegroups.com>
Content-Type: text/plain; charset="us-ascii"
There have been several good responses already, including Dan's
cautions.
It may be that your data are already in a SAS data set, with TIME as a
"time" variable. If so, you can format that variable within your PROC
SUMMARY and avoid an extra step as follows (adapted from Nat's example):
/* Assume this step was run previously */
data avg;
informat time time.;
format time time.;
input Year Month Day Time Speed;
* hour = hour(time);
cards;
2007 10 30 14:13 3.7
2007 10 30 14:14 5.7
2007 10 30 14:15 2.2
2007 10 30 14:16 3.7
2007 10 31 02:27 2.2
2007 10 31 03:15 3.3
run;
proc summary data = avg nway;
output out = avg mean = avg_speed;
var speed;
by year month day time;
format time hour2.;
run;
proc print;
Mike Rhoads
Westat
RhoadsM1@Westat.com
-----Original Message-----
From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu]
On Behalf Of firepit
Sent: Thursday, January 03, 2008 2:42 PM
To: sas-l@uga.edu
Subject: creating 1 hour averages
I am trying to create a 1 hour average for speed from data that looks
like:
Year Month Day Time Speed
2007 10 30 14:13 3.7
2007 10 30 14:14 5.7
2007 10 30 14:15 2.2
2007 10 30 14:16 3.7
Google hasn't been very helpful...