@val precision when extracting numbers from tables

For questions regarding programming in the EViews programming language.

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

J_Gascoigne
Posts: 13
Joined: Wed Apr 10, 2013 8:56 am
Location: London, UK

@val precision when extracting numbers from tables

Postby J_Gascoigne » Wed Apr 10, 2013 9:20 am

Hi - this is my first post here so apologies if it is in the wrong section or naive etc. I've used the search function already and can't find a similar post.

I want to assign a value from a cell in a a table to a control variable as part of a program in EViews 8, e.g.

!myvariable = @val(mytable(2,2))

this works in principle, but it seems to be reducing the accuracy to 6 decimal places when the number in the table is transferred to !myvariable, which is throwing subsequent calcualtions out. Is there any way to increase the accuracy (ideally to 16 decimals) or another way around this? Without the @val command I get a string assigned to scalar error.

For reference with alternative options, the !myvariable has to be used repeatedly taking different values from different cells as part of a loop, and the number has to come out of a table, and the table is the only source of the number (i.e. I can't get it from another object such as an equation).

Any help would be greatly appreciated.

JG

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

Re: @val precision when extracting numbers from tables

Postby EViews Gareth » Wed Apr 10, 2013 9:24 am

Unfortunately there is no way around it. It is one of the limitations of storing numbers in a table - they lose precision.

J_Gascoigne
Posts: 13
Joined: Wed Apr 10, 2013 8:56 am
Location: London, UK

Re: @val precision when extracting numbers from tables

Postby J_Gascoigne » Wed Apr 10, 2013 9:46 am

Actually I may have found a solution, inserting this line before extraction seems to have done the trick:

mytable.setformat(2,2) f.16

The @val precision seems to be restricted by the table format, but not the actual number entered (i.e. a 16 place decimal number was pasted in before using the setformat command. Pasting into the table doesn't lose accuracy, only extracting it if the default format is restrictive). This might be a change in EViews 8 as I don't remember this option before.

Thought I had exhuasted every option before posting but typically I thought of something else afterwards! Sorry to bother you, but thought I would post back in case someone else has a similar problem.

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

Re: @val precision when extracting numbers from tables

Postby EViews Gareth » Wed Apr 10, 2013 9:48 am

Ha, the same thought occurred to me after posting.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests