Very compact, as always. But it wouldn't work for a dataset with weekly or daily frequency, would it?

Jan Annaert

UNIVERSITEITANTWERPEN | Faculty of Applied Economics (TEW) | Dept. Accounting & Finance
Room  S.B.335 | Prinsstraat 13 | B-2000 Antwerp  | Belgium
Phone +32 32654163 |Fax +32 32654064

http://www.ua.ac.be/jan.annaert
http://ssrn.com/author=143473


From: "Riccardo Lucchetti (Jack)" <r.lucchetti@univpm.it>
Reply-To: "r.lucchetti@univpm.it" <r.lucchetti@univpm.it>, "gretl-users@lists.wfu.edu" <gretl-users@lists.wfu.edu>
Date: zondag 16 september 2012 22:40
To: "walt@dataanalyticscorp.com" <walt@dataanalyticscorp.com>, "gretl-users@lists.wfu.edu" <gretl-users@lists.wfu.edu>
Subject: Re: [Gretl-users] extracting month number

On Sun, 16 Sep 2012, Data Analytics Corp. wrote:

Hi,

I have a monthly time series of the Dow Jones Industrial Index beginning
1928:10.  I'd like to create a new variable that is just the month
number: 10, 11, 12, 1, 2, 3,....   How can I do this?  I thought there
would be a month function in Gretl, but I don't see one.  This question,
of course, extends to the year (1928, 1928, 1929, 1929,...) and quarter
if I have quarterly data.

Does this help?

<hansl>
open bjg.gdt
series year  = 1949 + floor((t-1)/12)
series month = 1 + ((t-1)%12)
</hansl>

--------------------------------------------------
  Riccardo (Jack) Lucchetti
  Dipartimento di Economia

  Università Politecnica delle Marche
  (formerly known as Università di Ancona)

  r.lucchetti@univpm.it
  http://www2.econ.univpm.it/servizi/hpp/lucchetti
--------------------------------------------------