Page 1 of 1

Simpler way to maximize control variables?

Posted: Thu Mar 07, 2013 2:05 am
by paues
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.)

Re: Simpler way to maximize control variables?

Posted: Thu Mar 07, 2013 2:26 am
by trubador
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

Re: Simpler way to maximize control variables?

Posted: Thu Mar 07, 2013 2:29 am
by paues
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.

Re: Simpler way to maximize control variables?

Posted: Thu Mar 07, 2013 2:52 am
by trubador
How about this one?

Code: Select all

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

Re: Simpler way to maximize control variables?

Posted: Thu Mar 07, 2013 3:12 am
by paues
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.