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!
Problem with recognition of decimals
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13319
- 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:
Then select individual elements of the table, you can see the numbers are not exact.
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.
Follow us on Twitter @IHSEViews
-
- EViews Developer
- Posts: 799
- 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 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
Thank you very much! It works!
Who is online
Users browsing this forum: No registered users and 34 guests