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]

Re: st: Renaming variables, bis


From   Neil Shephard <[email protected]>
To   [email protected]
Subject   Re: st: Renaming variables, bis
Date   Tue, 12 Apr 2011 11:42:55 +0100

On Tue, Apr 12, 2011 at 11:35 AM, BAIJER Jan 212040 <[email protected]> wrote:
>
> It so appears (...) that the intended variable names (first observation of each variable) have spaces inthem, so I would probably be looking to try to eliminate those by "subinstr", but I can't get that to work.
>
> I have tried several variants of :
>
> foreach var of varlist _all {
>
>    local NewVarName = subinstr ("`var'[1]'"," ","_")
>
>    ren `var' `NewVarName'
>
> }
>

Further you've made a fundamental error in understanding how Stata
handles spaces in variable names.

Spaces in variable names are not permitted in Stata, they're
automatically purged and the remaining text concatenated when using
-insheet-.  However, if you're using the suggested -infix- and
dictionary this won't be an issue as you will explicitly define the
variable names within your dictionary.

Neil
-- 
“Truth in science can be defined as the working hypothesis best suited
to open the way to the next better one.” - Konrad Lorenz

Email - [email protected]
Website - http://kimura.no-ip.org/
Photos - http://www.flickr.com/photos/slackline/

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