Page 1 of 1
How to change precision of a workfile?
Posted: Fri Jan 07, 2011 12:50 pm
by Liu
Hi.
I am using the program below to return the current date (year) as a variable so that I can use
it elsewhere (such as for charting, or for controlling sample range). However, when the string
was given to the scalar variable, it was rendered three extra digits (2011.000 instead of 2011).
Consequently, the pagestruct command doesn't recognize 2011.000 as a year string.
Can I change the precision of my workfile so that a scalar do not display digits after the decimal?
Thank you.
string end=@strnow("YYYY")
scalar enddate={end}
pagestruct(end=enddate)
How to change precision of a workfile?
Posted: Fri Jan 07, 2011 1:48 pm
by EViews Gareth
Use the @Val command when converting to a scalar
Re: How to change precision of a workfile?
Posted: Mon Jan 10, 2011 7:06 am
by Liu
Thank you for your reply.
I used @val, but the scalar still has the value of 2011.000 instead of 2011.
And the pagestruct command can not recognize it as a legal date format.
Code: Select all
wfcreate m 1998 2010
string year=@strnow("YYYY")
scalar enddate=@val(year)
pagestruct(end=enddate)
Re: How to change precision of a workfile?
Posted: Mon Jan 10, 2011 9:45 am
by EViews Gareth
The scalar has a value of 2011. It isn't that that is causing your error.
To do what you want to do, try this:
Code: Select all
wfcreate m 1998 2010
string year=@strnow("YYYY")
scalar enddate=@val(year)
pagestruct(end={enddate})
or, even easier, this:
Code: Select all
wfcreate m 1998 2010
string year=@strnow("YYYY")
pagestruct(end={year})
Re: How to change precision of a workfile?
Posted: Mon Jan 10, 2011 12:44 pm
by Liu
Thanks Gareth.
The reason I purposely create a scalar variable is that later I want to manipulate
this variable in other command lines such as charting, so that the charts can updates their range by themselves.
I tried the program below as you told me.
Code: Select all
wfcreate m 1998 2010
string year=@strnow("YYYY")
scalar enddate=@val(year)
pagestruct(start={enddate}-15, end={enddate})
but why the workfile didn't change its range to 1996 to 2011 but instead 2009M10 to 2011m12?
should it do scalar calculation first to be " pagestruct(start=(2011-15), end=2011)" ?
Re: How to change precision of a workfile?
Posted: Mon Jan 10, 2011 1:10 pm
by EViews Gareth
create an intermediary variable that has the calculation done. Something like:
Code: Select all
!start = enddate - 15
pagestruct(start = {!start}, end={enddate})
Re: How to change precision of a workfile?
Posted: Wed Jul 27, 2011 9:09 am
by Liu
Hi,
I met the precision problem again. I still have trouble controlling the number of decimals for a scalar variable.
The idea is to show the last date and value of a series in my chart.
scalar m=@ilast(series1)
string e=@otods(m)
!y=@last(series1)
string v=@str(!y)
%w="(" + e + ", " + v + ")"
graph c1p1.line s1
c1p1.addtext(0.15,0.4) {%w}
from this program, what shows on my chart however, is in the format like: ( 07/15/2011, 128.9485768574)
My question is: is there a way I can control how many digit the scalar variable displays?
I want it to bt 128.95 if that's possible.
Re: How to change precision of a workfile?
Posted: Wed Jul 27, 2011 9:13 am
by EViews Gareth
The @str command has an optional format argument that lets you control the format. The command reference has a full, detailed, listing of the formats, but for yours, you could probably get away with something like: