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

Re: st: RE: removing prefix


From   Ernest Berkhout <ernestb@seo.fee.uva.nl>
To   statalist@hsphsun2.harvard.edu, <statalist@hsphsun2.harvard.edu>
Subject   Re: st: RE: removing prefix
Date   Wed, 03 Sep 2003 10:28:30 +0200

> -----Original Message-----
> From: Ben.Kriechel@roa.unimaas.nl
> [mailto:Ben.Kriechel@roa.unimaas.nl]
> Sent: Wednesday, September 03, 2003 9:31 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: removing prefix
>
> 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?

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).


Ernest Berkhout
SEO Amsterdam Economics
University of Amsterdam

Room 3.08
Roetersstraat 29
1018 WB Amsterdam
The Netherlands

tel.:+ 31 20 525 1657
fax:+ 31 20 525 1686
http://www.seo.nl
===========================
A statistician: someone who insists
on being certain about uncertainty
===========================

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