Dear All,
I am struggling to compute a constant of products within a variable.
What I am trying to do is something very similar to what the 'egen'
command with the option 'sum' and 'by(.)' does, except that I would need
something like a multiplication option.
My dataset is a panel of monthly stock returns and I want to compute the
follwing:
- For each company and for each year: The product of (1+r_t) where r is
the monthly stock return in month t. More specifically, my dataset
looks like:
Company Year Month Return What I need:
Pi^12_1(1+r_t)
1 1990 1 .33 constant
for 1990 firm 1
1 1990 2 .44 constant
for 1990 firm 1
. . . . constant
for 1990 firm 1
. . . . constant
for 1990 firm 1
. . . . constant
for 1990 firm 1
1 1990 12 .55 constant
for 1990 firm 1
1 1991 1 .23 constant
for 1991 firm 1
1 1991 2 .43 constant
for 1991 firm 1
. . . . constant
for 1991 firm 1
. . . . constant
for 1991 firm 1
. . . . constant
for 1991 firm 1
1 1991 12 .43 constant
for 1991 firm 1
2 1990 1 .87 constant
for 1990 firm 2
2 1990 2 .98 constant
for 1990 firm 2
. . . . constant
for 1990 firm 2
. . . . constant
for 1990 firm 2
. . . . constant
for 1990 firm 2
2 1990 12 .65 constant
for 1990 firm 2
. . . . .
. . . . .
. . . . .
and so on for nearly 2,000 companies and ten years.
If any of you has any good suggestions I would greatly appreciate it,
especially if it can deal with missing return data.
Thanks for your help.
Best,
Mario
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/