sample using first and last of a series

For questions regarding programming in the EViews programming language.

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

miorinnovo
Posts: 174
Joined: Sun Mar 01, 2015 5:01 pm

sample using first and last of a series

Postby miorinnovo » Wed Mar 06, 2019 6:46 am

Hi,

I'd like to program a sample to start one month after the last observation of the series x, and end it one or two months later. I thought this would work

smpl @last(variablex) @last(variablex)+2

But it didnt work.

Can anyone offer another idea?

Thanks

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

Re: sample using first and last of a series

Postby EViews Gareth » Wed Mar 06, 2019 8:43 am

Store the dates in program variables first.

Code: Select all

%first = @ifirst(x)
smpl {%first}
Follow us on Twitter @IHSEViews

miorinnovo
Posts: 174
Joined: Sun Mar 01, 2015 5:01 pm

Re: sample using first and last of a series

Postby miorinnovo » Wed Mar 06, 2019 1:56 pm

I tried

Code: Select all

%last= @last(x)
smpl {%last} {%last}+3


and get the message 'scalar assigned to a string'.

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

Re: sample using first and last of a series

Postby EViews Gareth » Wed Mar 06, 2019 2:29 pm

use @ilast and @ifirst
Follow us on Twitter @IHSEViews

miorinnovo
Posts: 174
Joined: Sun Mar 01, 2015 5:01 pm

Re: sample using first and last of a series

Postby miorinnovo » Thu Mar 07, 2019 10:16 am

I tried

Code: Select all

%last= @ilast(variable)
smpl {%last} {%last}+3


and get the same error

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

Re: sample using first and last of a series

Postby EViews Gareth » Thu Mar 07, 2019 10:27 am

ha, been a while since I did this...

Code: Select all

%last = variable.@last
smpl {%last} {%last}+3
Follow us on Twitter @IHSEViews

miorinnovo
Posts: 174
Joined: Sun Mar 01, 2015 5:01 pm

Re: sample using first and last of a series

Postby miorinnovo » Thu Mar 07, 2019 12:53 pm

Now I get the error:

%LAST is not defined or is an illegal command in "%LAST = variable.@LAST".

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

Re: sample using first and last of a series

Postby EViews Gareth » Thu Mar 07, 2019 1:00 pm

Which version of EViews?
Follow us on Twitter @IHSEViews

miorinnovo
Posts: 174
Joined: Sun Mar 01, 2015 5:01 pm

Re: sample using first and last of a series

Postby miorinnovo » Thu Mar 07, 2019 1:57 pm

10+

EViews Matt
EViews Developer
Posts: 382
Joined: Thu Apr 25, 2013 7:48 pm

Re: sample using first and last of a series

Postby EViews Matt » Thu Mar 07, 2019 2:35 pm

Hello,

Is the name of your series "variable" or "variablex"? That (unhelpful) error message can appear if you use a non-existent series name.

miorinnovo
Posts: 174
Joined: Sun Mar 01, 2015 5:01 pm

Re: sample using first and last of a series

Postby miorinnovo » Thu Mar 07, 2019 3:05 pm

Thank you! it was a typo in the variable name.

miorinnovo
Posts: 174
Joined: Sun Mar 01, 2015 5:01 pm

Re: sample using first and last of a series

Postby miorinnovo » Fri Mar 22, 2019 6:31 am

Hi again,

Is there a way to use the %last from

Code: Select all

 %last =variable.@last
as the date with the @elem function?

right now I have

Code: Select all

series Variabless=@elem(variable, "2018m12")


and i'd like to replace 2018m12 with something that will automatically take the last date of variable

Thanks!

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

Re: sample using first and last of a series

Postby EViews Gareth » Fri Mar 22, 2019 7:05 am

Code: Select all

series Variabless=@elem(variable, %last)
Follow us on Twitter @IHSEViews

miorinnovo
Posts: 174
Joined: Sun Mar 01, 2015 5:01 pm

Re: sample using first and last of a series

Postby miorinnovo » Fri Mar 22, 2019 7:29 am

thanks


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 4 guests