defining %k=[group].@seriesname(!i)

For questions regarding programming in the EViews programming language.

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

bhaupt
Posts: 25
Joined: Fri May 07, 2010 1:16 pm

defining %k=[group].@seriesname(!i)

Postby bhaupt » Wed Aug 04, 2010 2:48 pm

I am using EViews 7.1.

I have several groupings to process which I need to do summary statistics for each except that each group has few a few extraneous members. As such, I'm working on a separate page from my main page with all relevant series groups, and looking to drop the extraneous series. We'll say that the series I want to summarize are defined as those starting with "USE" and invalid series start with anything else.

Likewise, for the data to be summarized properly, I actually need to convert any zero values to NAs.

So I figure, I can loop through the group, convert the values as necessary to NA, and then check each name and see if I should delete it from the grouping.

I can't. the [group].@seriesname(!i) even when assigned to a temp value does not get recognized as a series.

currently I've got the NA code commented out because solving the failure to drop "BADNAME" from the group should provide me enough insight to solve my NA problem.

Code: Select all

for !i = 1 to g_sc_sqft.@count %j = @left(g_sc_sqft.@seriesname(!i), 3) '# getting the preamble %k = g_sc_sqft.@seriesname(!i) '# getting the whole name of the series logmsg %j %k '# We'll say %j %k is "BAD" and "BADNAME" respectively ' smpl s_all if {k%}=0 ' {%k}=NA ' smpl s_all if %j <> "USE" then '# "USE01" "USE02" "USE03" do not enter this loop. logmsg "here" '# we do infact reach this point with "BAD" g_sc_sqft.drop {%k} '# neither %k or {%k} give the desired result, an indirect reference to the series "BADNAME" endif next

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

Re: defining %k=[group].@seriesname(!i)

Postby EViews Gareth » Wed Aug 04, 2010 2:56 pm

I can't see what could be wrong with that off the top of my head - could you provide a sample workfile that this code could run on?

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

Re: defining %k=[group].@seriesname(!i)

Postby EViews Gareth » Wed Aug 04, 2010 3:09 pm

Actually one thing did occur to me, although I'm not sure if it is the problem you are describing.

Your loop runs from 1 to group.@count. Thus if your group has 5 members it will run from 1 to 5. However inside the loop you're going to drop members from the group. Thus if you drop one member, your group will now only have 4 members, yet the loop is still going to run from 1 to 5. On the 5th run it will error since the group.@seriesname(5) doesn't exist.


I might do this a slightly different way:

Code: Select all

%allmembers = group.@members 'all members of the group %badmembers = @wdrop(%allmembers, "USE*") 'all the members of the group that don't match the USE* pattern group.drop {%badmembers} 'drop them for !i=1 to group.@count %name = group.@seriesname(!i) {%name} = @recode({%name}=0,NA,{%name}) 'recode all zeros to NAs next

bhaupt
Posts: 25
Joined: Fri May 07, 2010 1:16 pm

Re: defining %k=[group].@seriesname(!i)

Postby bhaupt » Thu Aug 05, 2010 5:56 am

Ah, you are right on the first part, that is what breaks it when I add in a loop counter. I could decrement my outer loop when the condition is met - but you've provided a more elegant solution. Thank you.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests