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]

st: RE: truncate variable names


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: truncate variable names
Date   Mon, 26 Jul 2010 15:43:37 +0100

renvars, trim(8) 

where -renvars- is downloadable from the SJ files. -search renvars- for
precise location. 

Note that the first principles solution 

foreach v of var * { 
	local new = substr("`v'", 1, 8) 
	rename `v' `new' 
}

is more instructive about principles but will fail part-way through if
two or more variable names have the same first 8 characters. -renvars-
warns you of that problem in advance, so that you can rethink strategy. 

By the way, this strikes me as mostly a bad idea unless you are
exporting to some other software that requires it. 

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

SCHOUMAKER Bruno

I would like to truncate the variable names of my dataset to 8
characters.

Does anybody know how I can do that in Stata ?


*
*   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