I'm trying to understand the syntax of EViews (7), but sometimes it just doesn't make sense. Two problems.
1. First:
Code: Select all
for !industry=1 to 10
!no_{!industry} = 0
for !firm=1 to 100
smpl 1/1/2010 1/1/2010 if d{!firm} = {!industry}
!no_{!industry} = !no_{!industry} + 1
smpl @all
next
next
I expected from the above code that it would create 10 variables (!no_1, !no_2, etc.), and at the end of the main loop, each of those variable will contain a number of firms having the specific industry code. But that doesn't work, and at the end of the loop, all of those variables have value of 100 (equal to a number of firms). That doesn't make sense, as there's a FOR statement, which increases a particular variable only if the first row fulfills the specific condition. For example, the statement
Code: Select all
smpl 1/1/2010 1/1/2010 if d{!firm} = 1
!no_1 = !no_1 + 1
smpl @all
Code: Select all
for !industry=1 to 10
!! smpl 1/1/2010 1/1/2010
!! series no_{!industry}
!! smpl @all
for !firm=1 to 100
smpl 1/1/2010 1/1/2010 if d{!firm} = {!industry}
!! series no_{!industry} = no_{!industry} + 1
smpl @all
next
!! !no_{!industry} = @mean(no_{!industry})
!! delete no_{!industry}
next
Now I want to reorganize the series by the industry code. For example, if firm 21, 72 and 98 have the same code (say 1), I want to create a new series: industry_1_1, industry_1_2, industry_1_3 containing values of d21, d72, and d98, respectively. So I add the following code (again, the new code is marked by the exclamation marks):
Code: Select all
for !industry=1 to 10
smpl 1/1/2010 1/1/2010
series no_{!industry}
smpl @all
for !firm=1 to 100
smpl 1/1/2010 1/1/2010 if d{!firm} = {!industry}
series no_{!industry} = no_{!industry} + 1
smpl @all
next
!no_{industry} = @mean(no_{!industry})
delete no_{!industry}
!! !count = 1
!! for !firm=1 to 100
!! smpl 1/1/2010 1/1/2010 if d{!firm} = {!industry}
!! series industry_{!industry}_{!count} = d{!firm}
!! !count = !count + 1
!! smpl @all
!! next
next
The result of the program is that it creates series: industry_1_1 to industry_1_100, industry_2_1 to industry_2_100, industry_3_1 to industry_3_100, etc. The series industry_1_1, industry_2_1, industry_3_1, etc. are the same.
Why does it not work?
