name series with for cycle

For questions regarding programming in the EViews programming language.

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

Eppichgyo
Posts: 11
Joined: Mon Mar 18, 2019 11:17 am

name series with for cycle

Postby Eppichgyo » Tue Mar 19, 2019 6:43 am

Hi,

I estimate equations on rolling time period. I want to freeze the outout with "last date of the rolling time period" extension.

E.g: currently I have data until 2018m12. And i want to name the table with extension _2017m12 (last date-12)

Here is my code:

Code: Select all


for !i=-12 to 0 step 12
   smpl 2000:1 {%last}+!i
      if !i=-12 then
         for %y {%items}
            eq_long_{%y}.cointreg(method=ccr, lag=a, info=sic, kern=bart, bw=andrews)
            eq_long_{%y}.makeresids ecm_{%y}
               if %y="meat" then
               estar_meat_ecm=1-exp(-(0.15*((ecm_meat*100-0*100)^2)))
               endif         
                  for !j=1 to 6 step 1
                     scalar sc_l_{%y}_!j=eq_long_{%y}.c(!j)
                  next   
                  vector(6) vecl_{%y}_{%last+!i}
                  for !j=1 to 6 step 1
                     vecl_{%y}_{%last+!i}(!j) = sc_l_{%y}_!j
                  next
                  if %y="agrmeat" then
                  smpl 2001:6 {%last}+!i
                  eq_short_{%y}.ls(cov=hac, covlag=a, covinfo=sic, covkern=bart, covbw=andrews)
                  freeze(t_{%y}_{%last+!i}) eq_short_{%y}
                  else
                  smpl 2000:1 {%last}+!i
                  eq_short_{%y}.ls(cov=hac, covlag=a, covinfo=sic, covkern=bart, covbw=andrews)
                  freeze(t_{%y}_{%last}) eq_short_{%y}
                  endif
               close t_*
         next



but the {%last+!i} code does not work.

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: name series with for cycle

Postby EViews Matt » Tue Mar 19, 2019 9:22 am

Hello,

The "{%last}+!i" expression works as part of a smpl statement, but not as a general expression elsewhere in an EViews program. You'll need to use the date manipulation functions to create the string you want. For example,

Code: Select all

%tmp = @datestr(@dateadd(@dateval(%last), !i, "MM"), "yyyyfmm")
vector(6) vecl_{%y}_{%tmp}

Eppichgyo
Posts: 11
Joined: Mon Mar 18, 2019 11:17 am

Re: name series with for cycle

Postby Eppichgyo » Tue Mar 19, 2019 11:46 am

Thnks for the tip, I'll try it


Return to “Programming”

Who is online

Users browsing this forum: Google [Bot] and 21 guests