Page 1 of 1

@dateadd

Posted: Sat Mar 31, 2018 2:25 pm
by tvonbrasch
Hi

I want to create a date string for 2 quarters ago, e.g., if we are currently in 2018:1 I want to generate the string "2017:3". I tried the command

Code: Select all

%qlag2= @datestr(@dateadd(@now ,-2,"Q"),"yyyy:q")
However, it does not work, see
dateadd.PNG
dateadd.PNG (43.67 KiB) Viewed 5104 times
How can I do this in another way?
Thomas

Re: @dateadd

Posted: Mon Apr 02, 2018 8:12 am
by EViews Gareth
It should (and for me, although we're now in Q2, so the result I had was Q4, did) work just fine. What were you doing with %qlag2?

Re: @dateadd

Posted: Tue Apr 03, 2018 12:29 am
by tvonbrasch
Hi

I did not do anything with it. It works now, since we are in the beginning april. However, when I generated the series (on March 31st) it did not work. I think it is related to the posts: http://forums.eviews.com/viewtopic.php? ... add#p60254 and http://forums.eviews.com/viewtopic.php? ... add#p49282.

How can i get around this? Is there another way of generating the string %qlag2 in a way that is stable and that will always work?

Thomas

Re: @dateadd

Posted: Tue Apr 03, 2018 8:55 am
by EViews Gareth
Ah, I'm an idiot for not seeing it before.

If you do:

Code: Select all

@dateadd(@now, -2, "Q")
on March 31st, EViews will minus 2 quarters (6 months) from 31st March. 31st March minus 6 months is 31st September, but that date doesn't exist, so it returns NA.

This is safer, and should always work:

Code: Select all

@dateadd(@datefloor(@now, "Q"), -2, "Q")

Re: @dateadd

Posted: Tue Apr 03, 2018 9:09 am
by tvonbrasch
Great, thanks Gareth
Thomas