Page 1 of 1
Loop with decimals
Posted: Thu Apr 26, 2018 10:41 am
by lpando08
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
Thanks for your help!
Re: Loop with decimals
Posted: Thu Apr 26, 2018 11:00 am
by EViews Gareth
Object names cannot contain periods/points.
Re: Loop with decimals
Posted: Thu Apr 26, 2018 2:40 pm
by lpando08
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
by EViews Matt
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
by EViews Gareth
Or, use @makevalidname
Re: Loop with decimals
Posted: Thu Apr 26, 2018 3:37 pm
by lpando08
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
by EViews Matt
Sure, go ahead and run it to find out.
Re: Loop with decimals
Posted: Thu Apr 26, 2018 3:46 pm
by lpando08
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
by EViews Matt
Did you accidentally type "hdebt_!i1" somewhere in your code?
Re: Loop with decimals
Posted: Thu Apr 26, 2018 11:13 pm
by lpando08
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
by EViews Matt
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