Date: Wed, 29 May 2002 18:51:14 -0400
Reply-To: Sigurd Hermansen <HERMANS1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Sigurd Hermansen <HERMANS1@WESTAT.COM>
Subject: Re: Avg subsets of values in a dataset
Content-Type: text/plain; charset="iso-8859-1"
I don't find any SAS function or format that condenses date values to weeks
of the year. Others may have a better idea of where to look.
A crude but simple solution chops the SAS date sequence into 7-day segments
and computes averages per segment:
date: mmddyy8. value
select distinct date,floor((date)/7) as yrWeek,avg(value) as avg
group by calculated yrWeek
Since the SAS date value of zero corresponds to a Friday, you may have to
use an offset to normalize the week value to a calendar week.
From: Gigi Lipori [mailto:pflugg@BELLSOUTH.NET]
Sent: Wednesday, May 29, 2002 5:39 PM
Subject: Avg subsets of values in a dataset
If I have a dataset that looks something like the following:
continue same thing for four or five years.
What's the easiest way to grab the 'weekly' averages, as well as highs and
lows for the week. For instance....Week 1/1 through 1/7, I would want to
output a record something like 1/1/01 1/7/01 41 0 59 (consider missing
values to be 0 -- format start day, end day, avg, low, high). Then I'd want
it to pick up for the next 7 days, and so forth.
I know how to do it in VB, but I have trouble following iterations in SAS.
Any help would be appreciated...Gigi