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


From   Duha Altindag <daltin2@tigers.lsu.edu>
To   statalist@hsphsun2.harvard.edu
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index