Simpler way to maximize control variables?

For questions regarding programming in the EViews programming language.

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

paues
Posts: 218
Joined: Fri Apr 15, 2011 7:16 am
Location: Stockholm, Sweden

Simpler way to maximize control variables?

Postby paues » Thu Mar 07, 2013 2:05 am

I have two control variables (containing date values) and I want to create a third control variable for the maximum of the two control variables. How do I do this? It should be really easy, but here I am, fiddling with matrices. Is there no simpler way than what I come up with below?

Code: Select all

!D1=@dateval("2012Q2","YYYY[Q]Q") !D2=@dateval("2012Q3","YYYY[Q]Q") matrix(2,1) Ds Ds.fill !D1, !D2 matrix mx=@cmax(Ds) !Dmax=mx(1,1) Delete Ds mx
(For the sake of simplicity I have explicitly written the dates in question. In the program I am trying to write I, of course, do not know which of the two date values is the larger.)

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: Simpler way to maximize control variables?

Postby trubador » Thu Mar 07, 2013 2:26 am

Here is an other way (not necessarily simpler, though):

Code: Select all

if @dateval("2012Q2","YYYY[Q]Q") > @dateval("2012Q3","YYYY[Q]Q") then !dmax = @dateval("2012Q2","YYYY[Q]Q") else !dmax = @dateval("2012Q3","YYYY[Q]Q") endif

paues
Posts: 218
Joined: Fri Apr 15, 2011 7:16 am
Location: Stockholm, Sweden

Re: Simpler way to maximize control variables?

Postby paues » Thu Mar 07, 2013 2:29 am

Thank you for that. But although I neglected to mention it in my original post I am looking for a solution that can be scaled to maximize over any number of values.

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: Simpler way to maximize control variables?

Postby trubador » Thu Mar 07, 2013 2:52 am

How about this one?

Code: Select all

!dmax=0 !d = @dateval("2012Q2","YYYY[Q]Q") if !d > !dmax then !dmax = !d endif

paues
Posts: 218
Joined: Fri Apr 15, 2011 7:16 am
Location: Stockholm, Sweden

Re: Simpler way to maximize control variables?

Postby paues » Thu Mar 07, 2013 3:12 am

Together with a loop that could be the one :D Should have thought about it myself, now that I see it. I was struggling to find something native to EViews - odd that there does not seem to be anything.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests