Dear Forum Members
First of all, I thank you for taking your time to read my question. In my workfile, I have stocks returns, an identifier for decile and another identifier for month. What I would like to do is:
First, sort the returns in each decile (I have 10 deciles in total)
Second, compute the average monthly returns by using the identifier for month in each decile.
I came up with the following code:
matrix(10,12) decilem
for !j=1 to 10 '10 deciles in total
smpl if decile_id=!j
for !i=1 to 12 '12 months in total
smpl if month_id=!i
decilem(!j,!i)=@mean(m_returns)
next
next
When I run this code, Eviews completely ignores the deciles and spits out the monthly averages for the whole sample. I would really appreciate if you could point out to me where I am making a mistake in this code.
Thank you
2 Stage Loop with 2 smpl commands
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: 2 Stage Loop with 2 smpl commands
Code: Select all
for !j=1 to 10 '10 deciles in total
for !i=1 to 12 '12 months in total
smpl if month_id=!i and decile_id=!j
decilem(!j,!i)=@mean(m_returns)
next
next
Re: 2 Stage Loop with 2 smpl commands
Thank you so much Gareth! The program now does what it is supposed to do.
Who is online
Users browsing this forum: No registered users and 2 guests
