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

# st: Calculating Industry Experience

 From "Lawal, Olusola O" To "'statalist@hsphsun2.harvard.edu'" Subject st: Calculating Industry Experience Date Thu, 13 Feb 2014 18:39:31 +0000

```I have over 100,000 observations and 200 variables on acquisitions and their directors, but 10
observations and 5 variables will be enough to show the problem.
My data looks like this
dir_id     year    SIC     TargetSIC        Acq
--------------------------------------------------
10043    2007    1111         .           0
10043    2007     .          1450         1
10043    2008    1113         .           0
10043    2009     .          1111         1
10043    2010    1111         .           0
13944    2007    1112         .           0
13944    2008    1113         .           0
13944    2009    5760         .           0
13944    2008    1113         .           0
13944    2009     .          5760         1
---------------------------------------------------

I am trying to calculate industry experience based on matching SIC with TargetSIC of the director (dir_id) which is the difference (in years) from a time when Acq = 1 to a time when Acq = 0. In a different format, what I would like to calculate is the variable IndustryExperience below.

dir_id     year    SIC     TargetSIC     Acq       IndustryExperience
--------------------------------------------------------------------
10043    2007    1111         .           0               .
10043    2007     .          1450         1               .
10043    2008    1113         .           0               .
10043    2009     .          1111         1               1 (2009 (1111 from TargetSIC) - 2007 (1111 from SIC))
10043    2010    1111         .           0               .
13944    2007    1112         .           0               .
13944    2008    1113         .           0               .
13944    2009    5760         .           0               .
13944    2008    1113         .           0               .
13944    2009     .          5760         1               1 (2009 (5760 from TargetSIC) - 2007 (5760 from SIC))
---------------------------------------------------------------------

The problem I have is that I don't know how to attach grab a specific year and make it a reference point for other years within the same dir_id.

I am fairly new to Stata, but I imagine a loop and a global variable would do the trick?
Any suggestions would be greatly appreciated!

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