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/