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]

st: Removing Spaces from Variable Labels


From   Dan Connor <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Removing Spaces from Variable Labels
Date   Sat, 20 Nov 2010 17:44:57 +0000

Hi all,

I have a series of survey-derived datasets, with about 700 variables in each. I need to merge them, which I can do. The problem is that the variable names are uninformative (they're called v1, v2, v3...), and are not in the same order in each dataset (eg, v3 might correspond to gender in one dataset, and level of education in another). Fortunately, the variable names are the same when the survey question was the same. So I'm planning to just change the variable name to the variable label, using this routine:

foreach var of varlist * {
local x : variable label 'v'
rename 'v' 'x'
label variable 'x' "'v'"
}

However (and here's the part I need help with), the variable labels contain spaces, sometimes special characters, and sometimes are longer than 32 characters. This means that they are invalid names, so my loop above won't work. Is there a good way to remove these spaces and such from the labels before I run the above loop?

Thanks-

Dan

---
Dan B. F. Connor
[email protected]


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