INQUIRE incorrectly calculates ending date

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
macro
Posts: 70
Joined: Thu Jul 16, 2015 3:01 pm

INQUIRE incorrectly calculates ending date

Unread post by macro »

I have code that, for performance reasons, inserts data into a nested hash and passes that hash into a procedure. I've run into strange behaviour, though, when using the INQUIRE instruction in that INQUIRE calculates the ending date of the series incorrectly. Here is a contrived example:

Code: Select all

calendar(q) 1950 1
allocate 2050:4

procedure testproc data
    type hash[series] data
    option integer maxlags 8
    
    * unpack data
    smpl 1969:1 2004:4
    set lgdpk = data("lgdpk")
    set lcnsk = data("lcnsk")
    set lcotherk = data("lcotherk")
    set dlp = data("dlp")
    set dlpxfe = data("dlpxfe")
    
    * determine start and end points
    local integer begin_est end_est
    
    inquire(regressorlist) begin_est end_est
    # lgdpk {0 to maxlags} lcnsk{0 to maxlags} lcotherk{0 to maxlags} dlp{0 to maxlags} dlpxfe{0 to maxlags}
    print 2000:1 2006:4 lgdpk lcnsk lcotherk dlp dlpxfe
    display %datelabel(begin_est) %datelabel(end_est)
end

* load data
open data "sandbox_data.xls"
    data(format = xls, org = columns) 1969:1 2004:4 lgdpk lcnsk lcotherk dlp dlpxfe
close data

* insert data into hash
declare hash[series] %data
declare string lbl
dofor lbl = "lgdpk" "lcnsk" "lcotherk" "dlp" "dlpxfe"
    set %data(lbl) 1969:1 2004:4 = %s(lbl)
    clear %s(lbl)
end dofor lbl

@testproc(maxlags = 8) %data
Data are attached. This displays

Code: Select all

ENTRY         LGDPK           LCNSK         LCOTHERK           DLP           DLPXFE
 2001:01     9.1302035       8.6943927       8.2677455       0.00818734      0.00695187
 2001:02     9.1262085       8.6965609       8.2541511       0.00447919      0.00295149
 2001:03     9.1254794       8.6991537       8.2482163      -0.00018243      0.00184027
 2001:04     9.1322491       8.7056394       8.2554324       0.00200492      0.00677969
 2002:01     9.1445424       8.7166708       8.2697190       0.00272752      0.00355467
 2002:02     9.1476561       8.7209864       8.2709173       0.00678644      0.00462943
 2002:03     9.1575301       8.7256222       8.2891890       0.00422948      0.00442778
 2002:04     9.1609610       8.7333526       8.2856954       0.00456929      0.00377970
 2003:01        NA              NA              NA              NA              NA
 2003:02        NA              NA              NA              NA              NA
 2003:03        NA              NA              NA              NA              NA
 2003:04        NA              NA              NA              NA              NA
 2004:01        NA              NA              NA              NA              NA
 2004:02        NA              NA              NA              NA              NA
 2004:03        NA              NA              NA              NA              NA
 2004:04        NA              NA              NA              NA              NA
 2005:01        NA              NA              NA              NA              NA
 2005:02        NA              NA              NA              NA              NA
 2005:03        NA              NA              NA              NA              NA
 2005:04        NA              NA              NA              NA              NA
 2006:01        NA              NA              NA              NA              NA
 2006:02        NA              NA              NA              NA              NA
 2006:03        NA              NA              NA              NA              NA
 2006:04        NA              NA              NA              NA              NA


1969:01 2004:04
The end date of 2004:04 is clearly incorrect. I'm using the newest build of RATS that's available (from the forum post earlier this week).
Attachments
sandbox_data.xls
(43 KiB) Downloaded 857 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: INQUIRE incorrectly calculates ending date

Unread post by TomDoan »

Don't use SMPL!!!!! That overrides almost any "calculated" sample calculations including INQUIRE.
macro
Posts: 70
Joined: Thu Jul 16, 2015 3:01 pm

Re: INQUIRE incorrectly calculates ending date

Unread post by macro »

Right, thank you. You've mentioned that to me before and I have avoided it scrupulously since then, except in this one instance, and it came back to bite me.
Post Reply