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

st: Populating a new variable based on comparisons between observations

From   Dalhia <>
Subject   st: Populating a new variable based on comparisons between observations
Date   Wed, 18 Mar 2009 12:18:48 -0700 (PDT)

hi, I need to do comparisons between observations, and create a new variable based on this comparison. Here is the situation. I have data on alliances between companies for the years 1962 to 2009. One aspect of this data is that sometimes the company name changes over time, but the permanent identifier (GVKEY) remains the same, and I need to find a way to identify the latest company name. The data looks like this

Deal_Number, Deal_Date, Company_Name, Company_GVKEY. 
1, 2006, Apple computer, APP
2, 2009, Apple Inc, APP
2, 2009, Microsoft, MS

Here, company_name has changed over time from "apple computer" to "apple inc" but the GVKEY remains the same (APP).  I want to create a new variable called "Latest_Company_Name" which is populated by the name in the observation which has the later Deal_Date.  

So I want the data to look like this:

Deal_Number; Deal_Date; Company_Name; Company_GVKEY; Latest_Company_Name. 
1, 2006; Apple computer; APP; Apple Inc
2, 2009; Apple Inc; APP; Apple Inc
3, 2009, Microsoft, MS, Microsoft

I will really appreciate any suggestions as to how to do the above. 

Thanks so much. I also would like to especially appreciate and thank this list for responses to previous questions. I don't think I could have made the progress I have on my research without this list.  A big thank you to the people who have taken the time to respond. I'm humbled by your generosity.    



*   For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index