Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: removing prefix


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: removing prefix
Date   Wed, 3 Sep 2003 12:58:26 +0100

Ben Kriechel

> I have a data set which uses different variable 
> prefixes for different
> waves of the panel. So the variable name of the first wave is:
> a_varname
>
> To work with all the waves using the same commands I 
> would like to
> remove the different prefixes (a_ for the first wave, b_ for the
> second and so on). To this end I used the "renpfix" 
> command. However I
> could not figure out how I could replace the prefix for 
> "nothing",
> i.e. I want to change
>
>       a_varname  ===> varname
>
> How can that be done?

Ernest Berkhout
 
> renpfix a_ will of course only work once, as you can't have 
> multiple 
> variables with the same name. You want either of the 
> following two options:
> 
> 1)      use a loop with the help of -foreach- around the 
> commands that you 
> want to act on multiple variables.
> 2)      use -reshape- . Read the manual for more information. Take 
> advantage of the knowledge that in most cases a long data 
> structure (all 
> wave stacked 'on top' of each other, sharing the same 
> variables) is more 
> convenient than a wide datastructure (the one you have now, 
> every wave 
> needing its own new variables).
> 

Another tool in this area is -renvars- from STB-60. 

Nick 
n.j.cox@durham.ac.uk 

*
*   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–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index