Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Ravindran, Kiron" <kiron.r@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: calculating age / tenure |

Date |
Thu, 8 Nov 2012 01:27:59 +0100 |

Thanks a lot Rebecca. That was elegant. I was trying to do some variant of this http://www.stata.com/support/faqs/data-management/first-and-last-occurrences/ and getting stuck Kiron On Thu, Nov 8, 2012 at 12:06 AM, Rebecca Pope <rebecca.a.pope@gmail.com> wrote: > So, if I understand your data & question, you've got something like > the following, right? > > Data: > clear > input str3 company1 str3 company2 allyyear > abc def 1972 > abc efg 1983 > abc ghi 2001 > def efg 1956 > def abc 1972 > def xyz 1999 > end > > If so, just do this: > sort company1 allyyear > by company1: gen exper = allyyear - allyyear[1] > > This gives you: > input str3 company1 str3 company2 allyyear > abc def 1972 0 > abc efg 1983 11 > abc ghi 2001 29 > def efg 1956 0 > def abc 1972 16 > def xyz 1999 43 > > Then you could just keep the 2nd observation per company1, which gives > you the first time they had any experience. Ditto 2. > > Hope this helps. > Rebecca > > > > __o __o > _`\ <,_ _`\ <,_ > (_)/ (_) (_)/ (_) > ========================= > > > On Wed, Nov 7, 2012 at 4:29 PM, Ravindran, Kiron <kiron.r@gmail.com> wrote: >> I know there should be a simple way of doing this. But am tying myself >> up in knots figuring this out. Perhaps someone here can help >> >> I have a table that looks like this Company1, Company2, Year of alliance >> >> I want to calculate three different measures. >> 1. Company 1's experience: i.e. Year of Alliance of the Company1 minus >> the first Year of Alliance of company 1. (this captures the number of >> years of experience Company 1 has by being in any alliance) >> >> 2. The same for company 2 >> >> 3. The alliance experience. The current year of alliance minus the >> year of alliance when this particular dyad of Company 1 and Company 2 >> had their first alliance >> >> Thanks in advance >> * >> * 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/

**References**:**st: calculating age / tenure***From:*"Ravindran, Kiron" <kiron.r@gmail.com>

**Re: st: calculating age / tenure***From:*Rebecca Pope <rebecca.a.pope@gmail.com>

- Prev by Date:
**RE: st: Keep data according to one data file's varlist** - Next by Date:
**st: Question on xtreg and the FE option** - Previous by thread:
**Re: st: calculating age / tenure** - Next by thread:
**st: Question on xtreg and the FE option** - Index(es):