Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: renaming variables based on long labels


From   daniel klein <klein.daniel.81@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: renaming variables based on long labels
Date   Thu, 21 Jul 2011 17:35:47 +0200

First, I do not see under which circumstances you would prefer long
variable names, too long to ever be typed out, to names like VAR1,
VAR2, etc. but you will probably have your reasons.

Second, abbreviations used in your examples are not unique to
-summarize-. It is used in every command producing output (e.g.
tabstat). A lot of those command are implemented  as ados. However,
unfortunatly nothing in these program's code will give you a hint how
Stata manages to come up with the abbreviations.

Third, and I hope this helps, there is an extended function called
-permname-, which creates valid variable names based on suggested
names. If you modify your code to read

foreach var of varlist VAR* {
	rename `var' `:permname `=strtoname("`: var lab `var''")''
}

you should not have the problem of invalid or already defined names.

Best
Daniel
*
*   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–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index