Page 1 of 1

FOR loops and @month headache

Posted: Thu May 26, 2016 9:02 pm
by Chthoniid
Appreciate the help I've been getting, but have it a new snag.

Series M is the date of each observation. E.g. 1993-08-26
I can't seem to figure out a way to extract just the month from this series, in a 1 to 12 format. Which I can use in the following FOR/NEXT loop.

(The actual year part in loop runs smoothly. It's just when I try creating a month control variable the loop fails- I get NA values instead).

for !year= 1993 to 2001
smpl if yr = !year
for !month= 1 to 12
smpl if M=!month
series Q1=@sumsby(q, collector_ser)
next
next

TIA, B

Re: FOR loops and @month headache

Posted: Thu May 26, 2016 11:40 pm
by EViews Gareth
Does M contain the full date or just the month?

Re: FOR loops and @month headache

Posted: Fri May 27, 2016 1:32 pm
by Chthoniid
Does M contain the full date or just the month?
M contains the full date. I can't seem to find a function/syntax that extracts just the month info

Re: FOR loops and @month headache

Posted: Fri May 27, 2016 2:17 pm
by Chthoniid
Got it, sorry, where date is the original date series

M=@datepart(date, "mm")