Bookmark and Share

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]

Re: st: Changing part of variable names


From   Maarten Buis <maartenlbuis@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Changing part of variable names
Date   Tue, 24 May 2011 15:16:20 +0200

On Tue, May 24, 2011 at 2:27 PM,  <live@gmx.net> wrote:
> I have the following problem: I have 11 separate Stata-files, each containing a cross-section for one specific year. The variables in each corss-section are the same, except for the names, which carry a year tag in the variable name, so there's e.g. income07 in the cross-section for 2007, and income08 in the one for 2008. Now, I want to transform these 11 files into one panel data set. Therefore, I need to rename the variables in each cross section (several hundreds per cross-section) such that they have the same name, i.e. income07 and income08 need to become incomeXX -otherwise "append" wouldn't work. How do I do this with a loop? Further complication: the year tag can be anywhere in the variable name, things like in07come, income07 or inco07me are possible.

The easiest solution is probably to use Nick Cox's -renvars-. You can
find it by typing in Stata -findit renvars-.

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany


http://www.maartenbuis.nl
--------------------------

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index