Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# st: Index

 From "Pavlos C. Symeou" To statalist@hsphsun2.harvard.edu Subject st: Index Date Wed, 11 Jan 2012 17:16:52 +0200

```Dear Statalisters,

```
Happy new year to all. I'd like to ask for your assistance regarding the following:
```
```
I have a number of companies for a number of years and each company sells its products in a number of markets in a year. For each market, I have the value of its sales (a proportion relative to the overall sales for the company in a year). I am interested in calculating an index for each company-year as following:
```
```
1) for each company-year I must compare each market with each other. If the two markets are the same I take their product and multiply it by 1. If the two markets are not the same, I take their product and multiply them by 2. The index should be the sum of all products.
```
```
From the example data below, the Index for Firm 1 in Year 1993 should be:
```(0.4 * 0.2 * 1) + (0.4 * 0.4 * 2) + (0.2 * 0.4 * 2) = 0.56

DATA

Firm   Year      Market    Market_sales    Index
1         1990    1              1
1         1991    1              1
1         1992    2              .3
1         1992    2             .1
1         1992    3              .15
1         1992    2             .15
1         1992    3             .15
1         1992    4             .15
1         1993    4              .40
1         1993    4             .20
1         1993    5             .40
2         1990    1              1
2         1991    1              1
2         1992    2              .3
2         1992    2             .1
2         1992    3              .15
2         1992    2             .15
2         1992    3             .15
2         1992    4             .15
2         1993    4              .40
2         1993    4             .20
2         1993    5             .40

Thanks,

Pavlos

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```