The single element of series to scalar

For questions regarding programming in the EViews programming language.

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

Afterall
Posts: 16
Joined: Tue May 27, 2014 7:49 am

The single element of series to scalar

Postby Afterall » Sun May 17, 2015 9:01 am

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)).
Attachments
worfile_mah.wf1
(36 KiB) Downloaded 354 times

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

Re: The single element of series to scalar

Postby EViews Gareth » Sun May 17, 2015 9:16 am

scalar element=@elem(mah02, "2014/07/07")

Afterall
Posts: 16
Joined: Tue May 27, 2014 7:49 am

Re: The single element of series to scalar

Postby Afterall » Sun May 17, 2015 9:48 am

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.

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

Re: The single element of series to scalar

Postby EViews Gareth » Sun May 17, 2015 10:33 am

Use a otod to calculate the corresponding date

Afterall
Posts: 16
Joined: Tue May 27, 2014 7:49 am

Re: The single element of series to scalar

Postby Afterall » Sun May 17, 2015 10:54 am

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.

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

Re: The single element of series to scalar

Postby EViews Gareth » Sun May 17, 2015 5:10 pm

Code: Select all

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

Afterall
Posts: 16
Joined: Tue May 27, 2014 7:49 am

Re: The single element of series to scalar

Postby Afterall » Fri Aug 07, 2015 1:37 am

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.

startz
Non-normality and collinearity are NOT problems!
Posts: 3797
Joined: Wed Sep 17, 2008 2:25 pm

Re: The single element of series to scalar

Postby startz » Fri Aug 07, 2015 5:50 am

One, perhaps inelegant, way to do it is

Code: Select all

smpl 12 12 a =277 'restore old smpl

Afterall
Posts: 16
Joined: Tue May 27, 2014 7:49 am

Re: The single element of series to scalar

Postby Afterall » Fri Aug 07, 2015 7:30 am

That is very elegant solution, but anyone know if exist some command for that.

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

Re: The single element of series to scalar

Postby EViews Gareth » Fri Aug 07, 2015 8:26 am

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.

Afterall
Posts: 16
Joined: Tue May 27, 2014 7:49 am

Re: The single element of series to scalar

Postby Afterall » Sun Aug 09, 2015 3:06 am

I will use both solutions.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 0 guests