Extracting data from multipel series

For questions regarding programming in the EViews programming language.

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

bananen
Posts: 13
Joined: Sun Mar 08, 2015 3:05 pm

Extracting data from multipel series

Postby bananen » Mon Mar 09, 2015 8:18 am

Good evening,

I'm trying to program a script to extract observations from different series into a new one. I have series in the naming format of aW_Y & bW_Y where W=week number and Y=year. Example: a01_06, b52_96. The observations are dated about 5 times a week, and I want to take the 7th last observation from every series, and input into a new time series. It would be greatly appreciated if someone could offer support.

Code: Select all

series new for !i = 1 to 53 for !j = 95 to 99 series new = A{i}_{j}.(@dateadd(@last, -7, "dd")) next next for !i = 1 to 53 for !j =00 to 99 series new = B{i}_{j}.(@dateadd(@last, -7, "dd")) next next
Attachments
test2.WF1
(635.21 KiB) Downloaded 294 times

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

Re: Extracting data from multipel series

Postby EViews Gareth » Mon Mar 09, 2015 8:56 am

Something like:

Code: Select all

%alist = @wlookup("a*", "series") for %j {%alist} smpl if {%j}<>na !obs = @obssmpl-7+1 %date = @otods(!obs) smpl {%date} {%date} series new = {%j} next %blist = @wlookup("b*", "series") for %j {%blist} smpl if {%j}<>na !obs = @obssmpl-7+1 %date = @otods(!obs) smpl {%date} {%date} series new = {%j} next

bananen
Posts: 13
Joined: Sun Mar 08, 2015 3:05 pm

Re: Extracting data from multipel series

Postby bananen » Mon Mar 09, 2015 11:38 am

Thank you very much Gareth! Works like a charm when the series are modified for missing values.

bananen
Posts: 13
Joined: Sun Mar 08, 2015 3:05 pm

Re: Extracting data from multipel series

Postby bananen » Wed Mar 25, 2015 8:30 am

I have another question. If I have a panel, and would like to extract the last value of each cross section, that is not NA, in a series, into a new one, and fill all observations within that cross section with the same value. How would one address this issue?

I made an example below. X symoblises the original series, and the line separates the cross sections.

Code: Select all

x y na 176,5 na 176,5 173 176,5 175 176,5 176,5 176,5 na 176,5 na 176,5 -------------- na 174 177 174 174 174 na 174 na 174
I tried experimenting with some new code but did not get it to work out. Would be grateful if you have some input.

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

Re: Extracting data from multipel series

Postby EViews Gareth » Wed Mar 25, 2015 10:23 am

Code: Select all

'make some data create a 1990 2000 10 rndseed 1 smpl if nrnd<0.6 series x = @floor(rnd*10)+160 smpl @all 'do the series generation for !i=1 to 10 'loop over the cross-sections smpl if @crossid=!i series y = @last(x) 'set series y equal to the last value in x next

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Extracting data from multipel series

Postby EViews Glenn » Wed Mar 25, 2015 11:04 am

Think this works a little better

Code: Select all

series adjtrend = @recode(x<>na, @trend, na) series lasttrend = @maxsby(adjtrend, @crossid) series y = @meansby(x, @crossid, "if @trend=lasttrend")

bananen
Posts: 13
Joined: Sun Mar 08, 2015 3:05 pm

Re: Extracting data from multipel series

Postby bananen » Mon Mar 30, 2015 2:57 am

Thanks for the idea and effort. Unfortunately, none of the suggestions did work out, as both of them filled y with the last value of x, from the last cross section.

Code: Select all

for !i=1 to 1018 smpl if @crossid=!i series adjtrend = @recode(x<>na, @trend, na) series lasttrend = @maxsby(adjtrend, @crossid) series y = @meansby(x, @crossid, "if @trend=lasttrend") next

Code: Select all

'make some data create a 1990 2000 10 rndseed 1 smpl if nrnd<0.6 series x = @floor(rnd*10)+160 smpl @all 'do the series generation for !i=1 to 10 'loop over the cross-sections smpl if @crossid=!i series y = @last(x) 'set series y equal to the last value in x next
Think this works a little better

Code: Select all

series adjtrend = @recode(x<>na, @trend, na) series lasttrend = @maxsby(adjtrend, @crossid) series y = @meansby(x, @crossid, "if @trend=lasttrend")

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

Re: Extracting data from multipel series

Postby EViews Gareth » Mon Mar 30, 2015 7:58 am

Did you try running our example codes?

bananen
Posts: 13
Joined: Sun Mar 08, 2015 3:05 pm

Re: Extracting data from multipel series

Postby bananen » Mon Mar 30, 2015 2:05 pm

Did you try running our example codes?
Yes, like I said, unfortunately none of the examples worked out. The code i posted was my attempt after running both your ideas first.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests