Page 1 of 1
How to Create a Series from Other Series
Posted: Tue Mar 06, 2012 8:39 pm
by kinon902003
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.
Re: How to Create a Series from Other Series
Posted: Tue Mar 06, 2012 11:33 pm
by EViews Gareth
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?
Re: How to Create a Series from Other Series
Posted: Tue Mar 06, 2012 11:57 pm
by kinon902003
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.
Re: How to Create a Series from Other Series
Posted: Wed Mar 07, 2012 9:10 am
by EViews Gareth
@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.
Re: How to Create a Series from Other Series
Posted: Wed Mar 07, 2012 12:12 pm
by EViews Glenn
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.
Re: How to Create a Series from Other Series
Posted: Thu Mar 08, 2012 1:31 am
by kinon902003
Thank you very much for your help! It works perfectly. :D
Re: How to Create a Series from Other Series
Posted: Mon Jul 22, 2013 11:01 am
by LXWatson
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
Re: How to Create a Series from Other Series
Posted: Mon Jul 22, 2013 11:53 am
by EViews Gareth
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.
Re: How to Create a Series from Other Series
Posted: Wed Jul 24, 2013 7:25 am
by LXWatson
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!
Re: How to Create a Series from Other Series
Posted: Wed Jul 24, 2013 7:55 am
by EViews Gareth
No and No :(
Re: How to Create a Series from Other Series
Posted: Wed Jul 24, 2013 10:10 am
by LXWatson
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
Re: How to Create a Series from Other Series
Posted: Wed Jul 24, 2013 11:13 am
by EViews Gareth
try:
Code: Select all
wfsave(type=excelxml, mode=update, noid) %outputfile1 range="Sheet12!b1" nonames @keep ei1 @smpl %lastm %lastm
Re: How to Create a Series from Other Series
Posted: Mon Jul 29, 2013 6:34 am
by LXWatson
Worked perfect!