Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: creating a variable of a firm's latest name


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: creating a variable of a firm's latest name
Date   Wed, 31 Jan 2007 21:56:59 -0000

gen name = name_98 
foreach v in name_99 name_00 { 
	replace name = `v' if trim(`v') != "" 
} 

However, you'd be better off -reshape-ing this to long.

Nick 
[email protected] 

Marilyn Ibarra
 
> In my firm level dataset I have the name of the firm in each 
> year.  However, the name of the firm may change over time.  
> How do I create the variable called "name" (below) that would 
> grab the latest name of the firm.  
> 
> 
> For example I want to create the variable "name" as follows: 
> 
> 
> Firm_ID      name_98   name_99     name_00          name
> 1              firm_x     firm_x    x_firm         x_firm
> 2              firm_y     firm_y                   firm_y
> 3                                   firm_z         firm_z
> 4              firm_o                              firm_o

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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