Page 1 of 1

Problem with recognition of decimals

Posted: Fri May 11, 2018 1:37 pm
by lpando08
Hello,

I have run this loop:

for !x=70 to 74 step 0.1
!h= !x*10
smpl if debt>!x
series hdebt_!h =1
smpl @all

smpl if debt<!x
series ldebt_!h=1
smpl @all
next

One of the series generated would be hdebt_709 when debt>70.9 but when I run the program it doesn't work, it shows this message "9999999 is not a member or procedure of hdebt_709 in series hdebt_!h=1". Which could be the problem?

Thank you!

Re: Problem with recognition of decimals

Posted: Fri May 11, 2018 2:03 pm
by EViews Gareth
Since computers cannot handle decimals precisely, you should not perform loop operations with a decimal step size (this is true of most programming languages, not just EViews).

Although you think that !x will follow the pattern 70 70.1 70.2 70.3 70.4 etc..., it will not.
For example, if you run this code:

Code: Select all

create u 10 table a !r=1 for !x=70 to 74 step 0.1 a(!r) = !x !r=!r+1 next show a
Then select individual elements of the table, you can see the numbers are not exact.

Re: Problem with recognition of decimals

Posted: Sun May 13, 2018 6:11 am
by EViews Steve
I think using integers in the for loop instead would work better:

Code: Select all

logmode l for !h=700 to 740 step 1 !x= !h/10 logmsg !x smpl if debt>!x series hdebt_!h =1 smpl @all smpl if debt<!x series ldebt_!h=1 smpl @all next

Re: Problem with recognition of decimals

Posted: Mon May 14, 2018 10:54 am
by lpando08
Thank you very much! It works!