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: Renaming variable to its label which includes spaces or colons or semi colons


From   Duha Altindag <[email protected]>
To   [email protected]
Subject   st: Renaming variable to its label which includes spaces or colons or semi colons
Date   Thu, 22 Apr 2010 17:02:29 -0500

Hi,

I want to rename a variable name to its label. A related topic was
discussed before and solution was provided conditional on the labels
are in "proper form" and unique.
My labels are not in proper form but unique. Specifically they start
with a number and they include improper characters such as ":".
There is actually a string function called -strtoname- that transforms
improper strings into proper ones. However I cannot get use that
command while defining a -local-
My code looks like the following:

foreach v of varlist `VARIABLES' {
   local x : variable label `v'
   local q_`v'  strtoname(`x')
   ren `v' `q_`v''
   label variable `q_`v'' "`v'"
}


And this is the message I receive:

( not allowed
r(101);

If I can define my macro q_`v' above such that it denotes the proper
name obtained from -strtoname- I guess I will be fine.
Any ideas?
*
*   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