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: RE: Re: Replacing certain characters in variable labels.
From
"Nick Cox" <[email protected]>
To
<[email protected]>
Subject
st: RE: Re: Replacing certain characters in variable labels.
Date
Fri, 9 Apr 2010 10:43:11 +0100
I guess that what you needed in the first version was
local a = subinstr("`a'","’","'",.)
rather than
local a: subinstr("`a'","’","'",.)
The code you ended up with is naturally fine too.
Nick
[email protected]
Anna Reimondos
After a bit more exploration I found the solution:
foreach i of varlist _all {
local a : variable label `i'
local a: subinstr local a "’" "'"
label var `i' "`a'"
}
On Fri, Apr 9, 2010 at 11:49 AM, Anna Reimondos <[email protected]> wrote:
> I am currently cleaning a dataset but am having some trouble with the
> variable labels. The variable labels are related to the wording of the
> actual question in the survey.
> For example for the first variable the variable name should "A
> woman's job is to stay at home?"
>
> However whenever apostrophes are displayed strangely so that in the
> dataset the name looks like "A woman’s job is to stay at home?".
>
> What I would like to do is to replace all occurrences of "’" with an
> apostrophe instead " ' ".
>
> I attempted to do this but it did not work and I am not really sure
> what I am doing...
>
> foreach i of varlist _all {
> local a: variable label `i'
> local a: subinstr("`a'","’","'",.)
> label var `i' "`a'"
> }
>
*
* 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/