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: renaming variables based on long labels
From
"Cohen, Elan" <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: renaming variables based on long labels
Date
Thu, 21 Jul 2011 14:00:18 +0000
Statalisters,
I have a dataset with variable names VAR1-VAR40. All variables have (pretty long) labels. I'm using
foreach var of varlist VAR* {
rename `var' `=strtoname("`:var lab `var''")'
}
to rename each variable according to their label. I'm running into a problem because the variable labels are not unique within the first 32 characters and so I'm getting "Relationship_of_interviewee_to_s already defined".
Can Stata automatically generate a unique name based on existing variables? This seems like it's possible based on the following output:
webuse bg2
renvars, prefix(longprefix)
su
where Stata truncates variables names and automatically finds a unique string to display for each variable (-findit renvars-).
Thanks for any help you can provide,
- Elan
--
Elan D Cohen, MS
Center for Research on Health Care Data Center
University of Pittsburgh
[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/