How to Create a Series from Other 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

kinon902003
Posts: 12
Joined: Tue Mar 06, 2012 7:26 pm

How to Create a Series from Other Series

Postby kinon902003 » Tue Mar 06, 2012 8:39 pm

I have 20 times series, from 1999m1 to 2011m12. How can I create a new series by programming containing only the first observations of these 20 series? This new series should only contain 20 observations. Thank you.

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

Re: How to Create a Series from Other Series

Postby EViews Gareth » Tue Mar 06, 2012 11:33 pm

You're going to have to think about what you want to do a bit more. A series has a set number of observations - the length of the workfile. In your case each series has 156 observations. Thus you cannot create a new series containing just 20 observations.

Perhaps you would be better off putting those numbers into a vector instead?

Also, what do you mean by the first observations? You mean the value for 1999m1, or do you mean the first available data point for each series?

kinon902003
Posts: 12
Joined: Tue Mar 06, 2012 7:26 pm

Re: How to Create a Series from Other Series

Postby kinon902003 » Tue Mar 06, 2012 11:57 pm

Thank you for your reply.

In fact, what I need to do is to calculate quintiles for the 20 series of each month. That means for 1999m1, I need to calculate the quintiles of that 20 observations across series. I need to calculate them in a row-wise way. However, I found that @quantile cannot do it in row-wise way (or horizontally). So I want to "transpose" the 20 series so that the first observations of these 20 series will become a series, so that I can apply @quantile to it.

How can I make the first observations of the 20 series into a vector? Can @quantile apply to a vector? By the way, the series have some missing data.

First observations mean the value for exactly 1999m1. Second observations mean the value for 1999m2.

Thank you for your help.

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

Re: How to Create a Series from Other Series

Postby EViews Gareth » Wed Mar 07, 2012 9:10 am

@quantile can apply to a vector.

Something like:

Code: Select all

vector(20) myvec smpl @first @first for !i=1 to 20 %series = G.@seriesname(!i) myvec(!i) = @max({%series}) next
Where G is the name of the group containing the 20 series.

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

Re: How to Create a Series from Other Series

Postby EViews Glenn » Wed Mar 07, 2012 12:12 pm

Can I play along? Here's an alternative that avoids the loop.

Code: Select all

smpl @first @first stomna(G, myvecttr) vector myvec = @transpose(myvecttr) delete myvecttr
This puts the first obs in G into a rowvector which we then transpose. Note that if all you want to do is compute the quantiles, then you can ignore the @transpose and apply the @quantile to MYVECTTR directly.

kinon902003
Posts: 12
Joined: Tue Mar 06, 2012 7:26 pm

Re: How to Create a Series from Other Series

Postby kinon902003 » Thu Mar 08, 2012 1:31 am

Thank you very much for your help! It works perfectly. :D

LXWatson
Posts: 10
Joined: Mon Jun 24, 2013 12:09 pm

Re: How to Create a Series from Other Series

Postby LXWatson » Mon Jul 22, 2013 11:01 am

I think I want to do something very similar to this (at least in spirit) in Eviews8.

I want to make a Yield Curve of expected inflation using a downloadable excel. The excel features thirty columns of series (expectations 30 years out) and the rows are monthly observations starting from 1982m1.

Is there a way I can take a specific observation period across the different series (what amounts to a rowvector) and arrange them into a columnvector that I can save in excel (using wfsave) so that I can make my graph in excel. Ideally, I'd like to do this in eviews so all the data manipulation occurs there, while the excel is only for graphing the values.

Thank you,

Luke

I programmed the following for giggles knowing it probably wouldn't work (and it didn't(, but it may help show what I'm aiming at:

%last: 2013:6
vector v1 = @transpose(EI1 EI2 EI3 EI4 EI5 EI6 EI7 EI8 EI9 EI10 EI11 EI12 EI13 EI14 EI15 EI16 EI17 EI18 EI19 EI20 EI21 EI22 EI23 EI24 EI25 EI26 EI27 EI28 EI29 EI30)
wfsave(type=excelxml, mode=update) %outputfile1 range="Sheet13" @keep v1 @smpl last last

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

Re: How to Create a Series from Other Series

Postby EViews Gareth » Mon Jul 22, 2013 11:53 am

Put the series in a group. Set the sample to the observation you want. Use STOM to convert the group into a (one-dimensional) vector. Use matrix.write to save the matrix as an Excel file.

LXWatson
Posts: 10
Joined: Mon Jun 24, 2013 12:09 pm

Re: How to Create a Series from Other Series

Postby LXWatson » Wed Jul 24, 2013 7:25 am

I just saw the reply, thanks!

A couple of questions:
1) Instead of writing to a new file, I'd like to save into an existing file (in this instance sheet 12 of an existing excel, designated as outputfile1). Is this possible?
2) Is it possible to get the data in a columnvector rather than a rowvector?

When I did the following code the data was sent to a new excel in a rowvector.

group g1 EI1 EI2 EI3 EI4 EI5 EI6 EI7 EI8 EI9 EI10 EI11 EI12 EI13 EI14 EI15 EI16 EI17 EI18 EI19 EI20 EI21 EI22 EI23 EI24 EI25 EI26 EI27 EI28 EI29 EI30
smpl 2012:7 2012:7
stom(g1,m1)
m1.write(t=xls) %outputfile1 range="Sheet12"

Thanks again!

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

Re: How to Create a Series from Other Series

Postby EViews Gareth » Wed Jul 24, 2013 7:55 am

No and No :(

LXWatson
Posts: 10
Joined: Mon Jun 24, 2013 12:09 pm

Re: How to Create a Series from Other Series

Postby LXWatson » Wed Jul 24, 2013 10:10 am

Bummer.

Ok, so I'm trying a new method of writing the values where I want them using wfsave and setting my range to specific cells. However, I have another issue using this way: wfsave includes the series names, so as a series is added, the name covers the previous value written in the cell above.

Is there a way to have wfsave NOT include the series name? I have used "noid" to get rid of the observation, but wfsave still includes the series name. I have seen that "nonames" exists but when I put in the following code, the program seemed to just ignore.


wfsave(type=excelxml, mode=update, noid, nonames) %outputfile1 range="Sheet12!b1" @keep ei1 @smpl %lastm %lastm
wfsave(type=excelxml, mode=update, noid, nonames) %outputfile1 range="Sheet12!b2" @keep ei2 @smpl %lastm %lastm

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

Re: How to Create a Series from Other Series

Postby EViews Gareth » Wed Jul 24, 2013 11:13 am

try:

Code: Select all

wfsave(type=excelxml, mode=update, noid) %outputfile1 range="Sheet12!b1" nonames @keep ei1 @smpl %lastm %lastm

LXWatson
Posts: 10
Joined: Mon Jun 24, 2013 12:09 pm

Re: How to Create a Series from Other Series

Postby LXWatson » Mon Jul 29, 2013 6:34 am

Worked perfect!


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests