Hello,
I´m running For-loops with numerical variables, just as an example:
rndseed 123
For !i = 1 to 1000
!w1 = @runif(0.1,1)
!w2 = @runif(0.1,1)
!w3 = @runif(0.1,1)
!w1n = (!w1)/(!w1 + !w2 + !w3)
!w2n = (!w2)/(!w1 + !w2 + !w3)
!w3n = (!w3)/(!w1 + !w2 + !w3)
series hdi!i = edu^(!w1n) * lexp^(!w2n) * inc^(!w3n)
next
As a result I´m getting the following object-order in my workfile: hdi1, hdi10, hdi100, hdi 1000, hdi101, hdi102, […], hdi11, hdi110, hdi111, hdi112 and so on
How can I create a “normal” order like this: hdi1, hdi2, hdi3, hdi4, hdi5, etc. ?
Thank you very much!
For loops with numerical variables - resulting object-order
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: For loops with numerical variables - resulting object-or
Code: Select all
For !i = 1 to 1000
!w1 = @runif(0.1,1)
!w2 = @runif(0.1,1)
!w3 = @runif(0.1,1)
!w1n = (!w1)/(!w1 + !w2 + !w3)
!w2n = (!w2)/(!w1 + !w2 + !w3)
!w3n = (!w3)/(!w1 + !w2 + !w3)
%str = @str(!i)
if (!i<100) then
%str = "0" + %str
endif
if (!i<10) then
%str = "00" + %str
endif
series hdi{%str} = edu^(!w1n) * lexp^(!w2n) * inc^(!w3n)
next
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: For loops with numerical variables - resulting object-or
Same idea but simpler form of the string conversion. The "i04" format string tells EViews to produce a 4 digit string integer representation with leading zeros.
Code: Select all
For !i = 1 to 1000
!w1 = @runif(0.1,1)
!w2 = @runif(0.1,1)
!w3 = @runif(0.1,1)
!w1n = (!w1)/(!w1 + !w2 + !w3)
!w2n = (!w2)/(!w1 + !w2 + !w3)
!w3n = (!w3)/(!w1 + !w2 + !w3)
%str = @str(!i, "i04")
series hdi{%str} = edu^(!w1n) * lexp^(!w2n) * inc^(!w3n)
nextRe: For loops with numerical variables - resulting object-or
Thank you very much! Both works! :D
Who is online
Users browsing this forum: No registered users and 2 guests
