Statalist


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

Re: st: Re: ST: editing variable names & labels


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: Re: ST: editing variable names & labels
Date   Wed, 23 Jan 2008 08:09:56 -0500

Eric Uslaner <[email protected]>:
I think you've had a number of responses as to why Stata doesn't do
this, and why it might be a bad idea.  That said, you can make Stata
do it by writing one short program, e.g.

prog rensheet
version 10.0
syntax [varlist]
qui {
preserve
loc n: word count `varlist'
cap set obs `n'
tempvar o
g `o'=""
loc i=1
foreach v of local varlist {
 replace `o'="`v'" in `i++'
}
keep `o'
ren `o' oldname
g newname=""
edit
g r="ren"
tempfile d
outfile r oldname newname if !mi(new) using `d', noq wide
restore
}
do `d'
end

and saving it to the appropriate place (see -help personal-) as
rensheet.ado.  The above is fairly easy to modify to include variable
labels, and an extension to -edit- value labels (while not
straightforward) would be possible with -uselabel-.  If I were going
to actually author and use such a program, I might first add a
required option to force the user to specify a file name in which to
save the resulting do file containing the -rename- commands, though
that seems antithetical to your desired outcome.

On Jan 22, 2008 11:10 AM, Eric Uslaner <[email protected]> wrote:
> Thanks Maarten and Nick for the responses so far, but I know of label, rename, and renvars (all great).  But I want to avoid having to rename and relabel 300 variables in successive commands.  What I am looking for is an editor/spreadsheet, as in SPSS's variable view.  That would save a ton of time.  As I see it now, using the data editor is far less cumbersome than 300 rename/label statements and renvars doesn't make the whole process that much easier.
>
> Any help would be appreciated.  And if not, why can't Stata do this as SPSS has?
>
*
*   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