FOR loops and @month headache

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

Chthoniid
Posts: 24
Joined: Mon Oct 22, 2012 6:02 pm

FOR loops and @month headache

Postby Chthoniid » Thu May 26, 2016 9:02 pm

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13583
Joined: Tue Sep 16, 2008 5:38 pm

Re: FOR loops and @month headache

Postby EViews Gareth » Thu May 26, 2016 11:40 pm

Does M contain the full date or just the month?

Chthoniid
Posts: 24
Joined: Mon Oct 22, 2012 6:02 pm

Re: FOR loops and @month headache

Postby Chthoniid » Fri May 27, 2016 1:32 pm

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

Chthoniid
Posts: 24
Joined: Mon Oct 22, 2012 6:02 pm

Re: FOR loops and @month headache

Postby Chthoniid » Fri May 27, 2016 2:17 pm

Got it, sorry, where date is the original date series

M=@datepart(date, "mm")


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests