## Problem with recognition of decimals

For questions regarding programming in the EViews programming language.

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

lpando08
Posts: 29
Joined: Tue Apr 03, 2018 1:13 pm

### Problem with recognition of decimals

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!

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

### Re: Problem with recognition of decimals

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 10table a!r=1for !x=70 to 74 step 0.1   a(!r) = !x   !r=!r+1nextshow a`

Then select individual elements of the table, you can see the numbers are not exact.

EViews Steve
EViews Developer
Posts: 530
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

### Re: Problem with recognition of decimals

I think using integers in the for loop instead would work better:

Code: Select all

`logmode lfor !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 @allnext`

lpando08
Posts: 29
Joined: Tue Apr 03, 2018 1:13 pm

### Re: Problem with recognition of decimals

Thank you very much! It works!