Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Calculating Industry Experience
From
Michael Barker <[email protected]>
To
[email protected]
Subject
Re: st: Calculating Industry Experience
Date
Fri, 14 Feb 2014 07:33:55 -0500
I think what you're trying to accomplish can be done with a merge.
clear
use original_data
keep if Acq==1
rename year Acqyear
drop SIC
rename TargetSIC SIC
save Acqdata
clear
use original_data
keep if Acq==0
merge m:1 dir_id SIC using Acqdata
drop _merge
gen Industry_Experience = Acqyear-year
You will still have to sort out cases when TargetSIC may match more
than one SIC, such as in this case:
>> 10043 2007 1111 . 0
>> 10043 2009 . 1111 1
>> 10043 2010 1111 . 0
Maybe drop if Industry_Experience < 0
Mike
On Thu, Feb 13, 2014 at 2:35 PM, Nick Cox <[email protected]> wrote:
> Sorry, but I am still lost here. Are you saying 2009 - 2007 = 1?
> Nick
> [email protected]
>
>
> On 13 February 2014 18:39, Lawal, Olusola O <[email protected]> wrote:
>> 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/
>
> *
> * 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/
*
* 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/