Extract coefs form different objects, double seasonal

For questions regarding programming in the EViews programming language.

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

clubmed
Posts: 81
Joined: Sun Nov 30, 2014 3:03 am

Re: Extract coefs form different objects, double seasonal

Postby clubmed » Sat May 13, 2017 4:10 pm

1/ with @wlookup @pagelist that i can rename all coefs series like this: d_{name of equation}_{name of page} (for @wlookup if i don't know what their names of equations), and the function @pageselect to switch between pages.
2/ equation eq02 have 4 coefs (@quarter=1 to @quarter=4).

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

Re: Extract coefs form different objects, double seasonal

Postby EViews Gareth » Sat May 13, 2017 7:02 pm

1)

Code: Select all

%mypages = @pagelist
for %page {%mypages}
   pageselect {%page}
   rename myseries d_{name of equation}_{%page}
next



2)
If Equation 2 only has 4 coefficients, why is this code referencing coefficient 4+!i where !i runs from 1 to 53?

Code: Select all

for !i=1 to 53
smpl if @datepart(@date,"ww")=!i
series d_{%eq} =  {%eq}.@coef(4+!i)
next
smpl @all
Follow us on Twitter @IHSEViews

clubmed
Posts: 81
Joined: Sun Nov 30, 2014 3:03 am

Re: Extract coefs form different objects, double seasonal

Postby clubmed » Sun May 14, 2017 3:25 pm

I have add 6 lines in the first of the code to rename the untitled pages to page_0!r, but it rename just the first page.
I get error message for my full program: 16 is not a valid index for vector-series-coefficient in "SERIES D_{%EQ} = EQ04.@COEF(4+12)".
Attachments
data+prg.zip
(7.78 KiB) Downloaded 243 times

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

Re: Extract coefs form different objects, double seasonal

Postby EViews Gareth » Mon May 15, 2017 8:20 am

I don't think you have a grasp on what for loops do/are for. I all we can do is suggest you read up on for loops (in any programming language), and start experimenting / practicing until you get the hang of them.

Always try to picture in your mind exactly what the for loop is doing at each stage.
Follow us on Twitter @IHSEViews

clubmed
Posts: 81
Joined: Sun Nov 30, 2014 3:03 am

Re: Extract coefs form different objects, double seasonal

Postby clubmed » Mon May 15, 2017 3:03 pm

There are always keywords in your answers, it's pleasure to read them :) .
first, i agree that i have not use a methodology "loop for" in my code. i have problem to rename my pages Untitled page01 Untitled1 page02 Untitled2 page03.......( i can use this code it works, but i prefer to use @pagecount in the future if i need to rename multi pages)

Code: Select all

for %1 %2 Untitled page01 Untitled1 page02 Untitled2 page03............etc
pagerename {%1} {%2}
next

second, i dont't now why i cannot extract all coefs, from my equations objects, manually it works.
could you look, if you can correct some mistakes.
Attachments
prg_gdp_test44.prg
(2.67 KiB) Downloaded 237 times

clubmed
Posts: 81
Joined: Sun Nov 30, 2014 3:03 am

Re: Extract coefs form different objects, double seasonal

Postby clubmed » Wed May 17, 2017 9:06 am

1/I have use this code to rename all Untitled pages page_1, page_2,...: but i get error message.

Code: Select all

%mypages = @pagelist
for !r=1 to @pagecount
%page="page_"+@str(!r,"r02")
for %1 %2 {%mypages} {%page}
pagerename {%mypages} {%page}
next
next

2/I dont't now why i cannot extract all coefs, from my equations objects, manually it works. how can extract all the coefs?
Any help would be grateful.

clubmed
Posts: 81
Joined: Sun Nov 30, 2014 3:03 am

Re: Extract coefs form different objects, double seasonal

Postby clubmed » Fri May 19, 2017 2:06 pm

How can rename my all pages untitled, by page_01 page_02....etc, and switch bitween pages and extract coefs from equations objects.
with my program and data.
Attachments
prg_gdp_test44.prg
(2.67 KiB) Downloaded 259 times
gdp_test3.wf1
(76.55 KiB) Downloaded 228 times

clubmed
Posts: 81
Joined: Sun Nov 30, 2014 3:03 am

Re: Extract coefs form different objects, double seasonal

Postby clubmed » Mon May 22, 2017 2:44 pm

Hello,
Are there a solution for my loop for, could someone help me. :cry:

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

Re: Extract coefs form different objects, double seasonal

Postby EViews Gareth » Mon May 22, 2017 3:49 pm

You need to figure this out for yourself.

Here's some code that will help you figure it out (or should!). Run it in a separate program on the same workfile.

Code: Select all

table a 'this is a table object created to show what's going on inside loops
a(1,1) = "Iteration"  'add some column titles to the table
a(1,2) = "%page"
a(1,3) = "!r"
!row=2  'this is a counter keeping track of which row of the table we're on
setmaxerrs 100 'set the maximum number of errors before halting to something big, so we can see what's going on.


' rename untitled pages  THIS IS YOUR CODE WITH SOME DEBUGGING LINES ADDED
%mypages = @pagelist
for %page {%mypages}
for !r=1 to @pagecount
a(!row,1) = !row-1   'set the first colum of the table equal to the iteration number (which since !row starts at 2, is just !row-1
a(!row,2) = %page 'set the second column equal to whatever %page is at the moment
a(!row,3) = !r 'set the third column equal to whatever !r is
!row = !row+1 'increase our counter by 1
pagerename {%page} page_0!r
next
next

show a
Follow us on Twitter @IHSEViews

clubmed
Posts: 81
Joined: Sun Nov 30, 2014 3:03 am

Re: Extract coefs form different objects, double seasonal

Postby clubmed » Wed May 24, 2017 1:50 pm

Thanks for this few lines, it was help me to understand the logic of loop for, now i can rename all pages with loop, but i get error message. i will look if i can solve this.... :roll: i hope


Return to “Programming”

Who is online

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