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]

Re: st: RE: truncate variable names


From   SCHOUMAKER Bruno <bruno.schoumaker@uclouvain.be>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: truncate variable names
Date   Tue, 27 Jul 2010 08:32:53 +0200

Nick, I agree I could do that in principle. But the thing is that my syntax is used to generate a large number of excel files containing cross-tabulation of variables; the names of the files are the names of the variables; and I use a word file with links to these files. So I would need to change the links to the excel files in the word file if the variable names (and file names) were changed...

So your solution helps me a lot :-)

Bruno

Le 26/07/2010 16:58, Nick Cox a écrit :
You can do exactly that if all the abbreviations to the first 8 letters are distinct. As said, you'd need to check that any way.

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

SCHOUMAKER Bruno

Thanks a lot !

I agree it may seem a bad idea; Actually, I had a program running with
variables names truncated to 8 characters (exported from SPSS using an
old stat/transfer version) -  I received a new data set (same data, but
with additional observations), exported from SPSS with a new version of
stat/transfer, but with variables names longer than 8. And it would save
me a lot of time if I could just re run the syntax with exactly the same
variable names...

Le 26/07/2010 16:43, Nick Cox a écrit :

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


--
Bruno SCHOUMAKER

Centre de recherche en démographie et sociétés
Université catholique de Louvain
1-17 PLace Montesquieu
1348 Louvain-la-Neuve
BELGIUM

Tel. +32 10 474136
Fax. +32 10 472952

bruno.schoumaker@uclouvain.be
www.uclouvain.be/demo

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