Path: news.mathworks.com!newsfeed-00.mathworks.com!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!feeder.erje.net!feeder.eternal-september.org!eternal-september.org!not-for-mail
From: dpb <none@non.net>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Summarizing yearly/monthly data in time series
Date: Wed, 28 Oct 2009 16:09:33 -0500
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <hcac7v$3d5$1@news.eternal-september.org>
References: <hcaam2$8dv$1@fred.mathworks.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.eternal-september.org U2FsdGVkX1/Qi/iY6tiU+p0L9RfJbYOHfZvU+WO7y2Wra7WzTo9MoWCGoOo5LYudGmEjoXFxsJrJfxKfi2TjospcIR16Z9HFsDdWJ9hwjsv986v4cuKg7vdv3vJlpzlrcCXjITftU0k=
X-Complaints-To: abuse@eternal-september.org
NNTP-Posting-Date: Wed, 28 Oct 2009 21:14:40 +0000 (UTC)
In-Reply-To: <hcaam2$8dv$1@fred.mathworks.com>
X-Auth-Sender: U2FsdGVkX1+7A2Qqgs27OvmXDhxUp/XzVToO0JjhNrw=
Cancel-Lock: sha1:BKKvFV8Hf1jdd4V8uaZeLC0FeeA=
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
Xref: news.mathworks.com comp.soft-sys.matlab:580776


Ryan Utz wrote:
> Hi all,
> 
> I have a time series dataset that consists of daily data over several
> years. Most of the analyses are run on a matrix where the first
> column is the year, the second the month, the third the day and the
> final column is the data of interest. I want to do some simple
> summary statistics (sum of the data, for instance) for each month. I
> was assuming I'd do this in a for-loop.
> 
> Normally, I would identify each unique month using the 'unique' and
> 'find' commands  in the for-loop but since there is a month AND year
> I'm not quite sure how to do it. I have figured out that 'find' may
> include conditionals (i.e. '&') but still can't get to the bottom of
> it...
> 
> Also, I know I can use the 'consolidator' macro to do this quite
> easily, but I'm trying to write my own script for use by others and
> don't want to make the users download 'consolidator' as well.
> 
> Any takers?

I'd suggest turning the y/m/d columns into date numbers and then use 
date ranges on them instead of trying to do it on individual values.

--