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?
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
How to change precision of a workfile?
Use the @Val command when converting to a scalar
Re: How to change precision of a workfile?
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.
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)-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: How to change precision of a workfile?
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:
or, even easier, this:
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})
Code: Select all
wfcreate m 1998 2010
string year=@strnow("YYYY")
pagestruct(end={year})
Re: How to change precision of a workfile?
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.
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)" ?
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})should it do scalar calculation first to be " pagestruct(start=(2011-15), end=2011)" ?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: How to change precision of a workfile?
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?
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.
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.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: How to change precision of a workfile?
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:
Code: Select all
string v = @str(!y, "f.2")
Who is online
Users browsing this forum: No registered users and 2 guests
