Page 1 of 1

The single element of series to scalar

Posted: Sun May 17, 2015 9:01 am
by Afterall
Hello!
Anyone know how to get the single element of series to scalar. I'm trying to do that with the @elem.
I've tryed the simple code in programing:

scalar j=1000
scalar element=@elem(mah02, j)

And don't work. So the question is how to get the value of teh series to scalar. (The n (1000) element of series or maybe the element by data (for example: 7/07/2014)).

Re: The single element of series to scalar

Posted: Sun May 17, 2015 9:16 am
by EViews Gareth
scalar element=@elem(mah02, "2014/07/07")

Re: The single element of series to scalar

Posted: Sun May 17, 2015 9:48 am
by Afterall
That's work well. And what if I need the value of the element 1000 (The element who is 1000 in the order in serie.) element of series.

Re: The single element of series to scalar

Posted: Sun May 17, 2015 10:33 am
by EViews Gareth
Use a otod to calculate the corresponding date

Re: The single element of series to scalar

Posted: Sun May 17, 2015 10:54 am
by Afterall
Well the problem is because I need the scalar of "j" element in series because I'm trying to use scalar in for loop.;

!step=1
for !i =1000 to 1200 step !step
scalar j=!i
scalar element=@elem(mah02, j)
next

I need this for loop also because I will use scalar element in different sample for forecast. But this is a next step. First I want to know how I can use the @elem function. I know the algorithm for my final problem but I have a problems with program coding.

Re: The single element of series to scalar

Posted: Sun May 17, 2015 5:10 pm
by EViews Gareth

Code: Select all

%date = @otod(!i) scalar element = @elem(mah02, %date)

Re: The single element of series to scalar

Posted: Fri Aug 07, 2015 1:37 am
by Afterall
The code with j element of series works good. One another question. What if I need to change the single element of series. For example; If I need to replace the 12. element of series (who is now 234) to value 277. So, how to replace one single element of series with scalar.

@elem(series a, 12)=277

That's not work. They could be some other command, but I can't found them.

Re: The single element of series to scalar

Posted: Fri Aug 07, 2015 5:50 am
by startz
One, perhaps inelegant, way to do it is

Code: Select all

smpl 12 12 a =277 'restore old smpl

Re: The single element of series to scalar

Posted: Fri Aug 07, 2015 7:30 am
by Afterall
That is very elegant solution, but anyone know if exist some command for that.

Re: The single element of series to scalar

Posted: Fri Aug 07, 2015 8:26 am
by EViews Gareth

Code: Select all

a(12) = 277
Be very careful with that syntax though - it is easy to get confused a(12) can also mean the 12 period lead on a.

Re: The single element of series to scalar

Posted: Sun Aug 09, 2015 3:06 am
by Afterall
I will use both solutions.