Page 1 of 1

Loop with decimals

Posted: Thu Apr 26, 2018 10:41 am
Hello, I'm trying to run this, I mean I want to generate hdebt_10, hdebt_10.5, hdebt_11 up to hdebt_12, the same for ldebt. But Eviews canĀ“t generate hdebt_10.5, I do not why. It shows a message like this "5 is not a member or procedure of hdebt_10 in "series hdebt_!x"=1" How I can compute the series with decimals?

for !x=10 to 12 step 0.5
smpl if debt>!x
series hdebt_!x=1
smpl @all

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

call regressions
next

Re: Loop with decimals

Posted: Thu Apr 26, 2018 11:00 am
Object names cannot contain periods/points.

Re: Loop with decimals

Posted: Thu Apr 26, 2018 2:40 pm
I'm trying to run this to generate hdebt_105=1 when debt>10.5... because I can't generate hdebt_10.5 because of the point bu it doesn't work. How I could do this?

for !x=10 to 12 step 0.5
smpl if debt>!x
for !i=100 to 120 step 5
series hdebt_!i=1
smpl @all

for !x=10 to 12 step 0.5
smpl if debt<!x
for !i=100 to 120 step 5
series ldebt_!i=1
smpl @all

string grps = "hdebt_!i ldebt_!i"
call regressions
next
next
next
next

Re: Loop with decimals

Posted: Thu Apr 26, 2018 3:24 pm
Hello,

You can create a string version of the number and then use @replace to remove the ".", e.g., @replace(@str(!x), ".", "").

Re: Loop with decimals

Posted: Thu Apr 26, 2018 3:33 pm
Or, use @makevalidname

Re: Loop with decimals

Posted: Thu Apr 26, 2018 3:37 pm
I have tried to run it like this, it could work?

for !x=10 to 12 step 0.5
!i=!x*10
smpl if debt>!x
series hdebt_!i=1
smpl @all

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

Re: Loop with decimals

Posted: Thu Apr 26, 2018 3:40 pm
Sure, go ahead and run it to find out.

Re: Loop with decimals

Posted: Thu Apr 26, 2018 3:46 pm
Ok, it doesn't, it generates hdebt_100 but then a message window error shows that it hadn't find " hdebt_1001". I don't know why from hdebt_100 it goes to hdebt_1001.

Re: Loop with decimals

Posted: Thu Apr 26, 2018 4:21 pm
Did you accidentally type "hdebt_!i1" somewhere in your code?

Re: Loop with decimals

Posted: Thu Apr 26, 2018 11:13 pm
No, there is no a 1. It is weird, however if I want to use what you said, the code @replace to have hdebt_105 instead of hdebt_10.5 that is not possible, where I have to put this code @replace(@str(!x), ".", "") ? Thank you very much for your help.

for !x=10 to 12 step 0.5
smpl if debt>!x
series hdebt_!x=1
smpl @all

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

Re: Loop with decimals

Posted: Fri Apr 27, 2018 8:59 am
Creating a string to hold the result of that expression will work, e.g.,

Code: Select all

`string tmp = @replace(@str(!x), ".", "")series hdebt_{tmp}=1`