@dateadd

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Jason, EViews Moderator, EViews Pamela

tvonbrasch
Posts: 342
Joined: Fri Apr 15, 2011 5:35 am

@dateadd

Postby tvonbrasch » Sat Mar 31, 2018 2:25 pm

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 293 times


How can I do this in another way?
Thomas

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

Re: @dateadd

Postby EViews Gareth » Mon Apr 02, 2018 8:12 am

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?
Follow us on Twitter @IHSEViews

tvonbrasch
Posts: 342
Joined: Fri Apr 15, 2011 5:35 am

Re: @dateadd

Postby tvonbrasch » Tue Apr 03, 2018 12:29 am

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?f=9&t=18887&p=60254&hilit=%40dateadd#p60254 and http://forums.eviews.com/viewtopic.php?f=9&t=14319&p=49282&hilit=%40dateadd#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

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

Re: @dateadd

Postby EViews Gareth » Tue Apr 03, 2018 8:55 am

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")
Follow us on Twitter @IHSEViews

tvonbrasch
Posts: 342
Joined: Fri Apr 15, 2011 5:35 am

Re: @dateadd

Postby tvonbrasch » Tue Apr 03, 2018 9:09 am

Great, thanks Gareth
Thomas


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 4 guests