Dummy variables: Creating by mapping to an Alpha series.

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

Vladimir_Yorrick
Posts: 16
Joined: Tue Oct 14, 2008 12:40 am

Dummy variables: Creating by mapping to an Alpha series.

Postby Vladimir_Yorrick » Wed Jan 27, 2010 10:41 pm

Hi,

I am using EViews 7.

In an undated workfile with range = 15 I have an alpha series named Country:
Country = {AUT, AUT, AUT, BLX, BLX, BLX, BLX, BGR, BGR, CYP, CYP, CYP, CYP, CYP, CZE}.

Is there an easy way for me to create the following five dummies?
d_AUT = {1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
d_ BLX = {0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0}
d_BGR = {0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0}
d_CYP = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0}
d_CZE = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}

The commands below don't work but I hope it shows what I'm trying to do:

for %ctr AUT BLX BGR CYP CZE
series d_{%ctr} = stick a one in the same element when @elem(Country) = {%ctr}
next

or

for %ctr AUT BLX BGR CYP CZE
series d_{%ctr} = @recode(Country = {%ctr},"1","0")
next

Thanks in advance for any suggestions.

Vlad.

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

Re: Dummy variables: Creating by mapping to an Alpha series.

Postby EViews Gareth » Thu Jan 28, 2010 8:33 am

The best way is probably just to make an automatic group from them:

group g @expand(country)

Vladimir_Yorrick
Posts: 16
Joined: Tue Oct 14, 2008 12:40 am

Re: Dummy variables: Creating by mapping to an Alpha series.

Postby Vladimir_Yorrick » Fri Jan 29, 2010 12:55 am

Thanks Gareth.

I'm still having some problems with this.

FYI, my alpha series Country is a lot larger than 15 observations and contains country codes that are not listed in alphabetical order.

After creating the group g, the group members will be:
CODE="AUT"
CODE="BLX"
CODE="BGR"
CODE="CYP"
CODE="CZE"

How would I then:
- create 5 series objects
- where each series is equal to the appropriate 'column' of the group
- and have each series automatically named d_AUT, d_BLX, d_BGR, d_CYP and d_CZE?

If these commands
for !i = 1 to 5
series d_{g.@seriesname({!i})} = g({!i})
next
were to work (which they don't) I would end up getting series with names like:
d_CODE="AUT"
d_CODE="BLX",
etc.

Vlad.

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

Re: Dummy variables: Creating by mapping to an Alpha series.

Postby EViews Gareth » Fri Jan 29, 2010 9:03 am

Your original code, with a tweak, might be the way to go then:

for %ctr AUT BLX BGR CYP CZE
series d_{%ctr} = @recode(Country = %ctr,1,0)
next

Vladimir_Yorrick
Posts: 16
Joined: Tue Oct 14, 2008 12:40 am

Re: Dummy variables: Creating by mapping to an Alpha series.

Postby Vladimir_Yorrick » Mon Feb 01, 2010 11:03 pm

Thanks Gareth, that worked.

Vlad.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 1 guest