Transpose

For questions regarding programming in the EViews programming language.

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

BK03
Posts: 13
Joined: Tue Nov 10, 2015 5:35 am

Re: Transpose

Postby BK03 » Fri Nov 13, 2015 8:36 am

Also wondering how I would delete all series that have ONLY #N/A's in them. I found some posts about deleting series' with #N/A but this applies to series' with any #N/As

Thank you and happy Friday 13th :wink:

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

Re: Transpose

Postby EViews Gareth » Fri Nov 13, 2015 8:40 am

Hi Glen and Gareth,

I am working on a program and am trying to figure out how to specify a loop command for a particular worksheet in Eviews.

I load in 2 excel worksheets from the same workbook which become separate Eviews tabs. Howver, when I try to execute a loop it does it to both tabs in the EViews workfile!

Many thanks
I don't understand this question.

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

Re: Transpose

Postby EViews Gareth » Fri Nov 13, 2015 8:41 am

Also wondering how I would delete all series that have ONLY #N/A's in them. I found some posts about deleting series' with #N/A but this applies to series' with any #N/As

Thank you and happy Friday 13th :wink:
You can use series.@obs to return the number of non NA values in a series.

BK03
Posts: 13
Joined: Tue Nov 10, 2015 5:35 am

Re: Transpose

Postby BK03 » Fri Nov 13, 2015 8:59 am

Below is the code I use. When I run the series avg_{%h}_bs_{%i} command below it also tries to do this for the second tab (resulting in an error) where it obviously can't find the _bs_ as they are only on the first page.

wfcreate(wf=semi-annual) s 1990 2017
%mypath = @runpath
cd %mypath

'loads first sheet of Excel file where BS data is

pageload(page="Stoxx600_BS") Stoxx600_dataS.xlsx byrow range="EViews1" @freq s 1990s1
pageload(page="Stoxx600_IS") Stoxx600_dataS.xlsx byrow range="EViews2" @freq s 1990s1

'creates average of all variables by dividing totals by number of observations

for %h Cons_Disc Cons_Stap Energy Fin Health Indust IT Mat Telecom Utilities Tot Tot_xFin Tot_xEn Tot_xFE
for %i cash acctrcv invent netfxda totasst LTdebt totliab retearn toteq totlns llrsrv dmddepo STbrrw

series avg_{%h}_bs_{%i} = {%h}_bs_{%i} /{%h}_bs_obs{%i}

next
next

BK03
Posts: 13
Joined: Tue Nov 10, 2015 5:35 am

Re: Transpose

Postby BK03 » Fri Nov 13, 2015 9:03 am

I found this on a previous answer you provided. Does this delete objects with ONLY #N/As.

group g*
for !i=1 to g.@count
%name = g.@seriesname(!i)
if @obs({%name}) = 0 then
d {%name}
endif
next

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

Re: Transpose

Postby EViews Gareth » Fri Nov 13, 2015 9:29 am

Below is the code I use. When I run the series avg_{%h}_bs_{%i} command below it also tries to do this for the second tab (resulting in an error) where it obviously can't find the _bs_ as they are only on the first page.

wfcreate(wf=semi-annual) s 1990 2017
%mypath = @runpath
cd %mypath

'loads first sheet of Excel file where BS data is

pageload(page="Stoxx600_BS") Stoxx600_dataS.xlsx byrow range="EViews1" @freq s 1990s1
pageload(page="Stoxx600_IS") Stoxx600_dataS.xlsx byrow range="EViews2" @freq s 1990s1

'creates average of all variables by dividing totals by number of observations

for %h Cons_Disc Cons_Stap Energy Fin Health Indust IT Mat Telecom Utilities Tot Tot_xFin Tot_xEn Tot_xFE
for %i cash acctrcv invent netfxda totasst LTdebt totliab retearn toteq totlns llrsrv dmddepo STbrrw

series avg_{%h}_bs_{%i} = {%h}_bs_{%i} /{%h}_bs_obs{%i}

next
next
You've explicitly told EViews to load/create a 2nd page. Everything you do after creating that 2nd page will only apply to that page.

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

Re: Transpose

Postby EViews Gareth » Fri Nov 13, 2015 9:30 am

I found this on a previous answer you provided. Does this delete objects with ONLY #N/As.

group g*
for !i=1 to g.@count
%name = g.@seriesname(!i)
if @obs({%name}) = 0 then
d {%name}
endif
next
There's an easy way to find out.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests