Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Unable to use "replace" on specific values (but others work ok)

From   Anna Reimondos <>
Subject   Re: st: Unable to use "replace" on specific values (but others work ok)
Date   Fri, 19 Oct 2012 09:43:40 +1100

Thanks for the tip about filefilter. Will definitely use that!

I have finally discovered what is happening I think. As mentioned I am
working with occupation coding.

*Long answer
Each respondent is manually coded based on what they described their
occupation to be in an open text question. As there are 2000+ cases, I
have tried to streamline the procedure by first working from an excel

The excel spreadsheet has a column for the id of the respondent,
another couple of columns with the occupation description. Finally
there is a column for the ANZSCO code which I am filling in. The code
is derived by searching for occupations on the Australian Bureau of
Statistics website.
For example I search for a 'massage therapist' and find that the code
is 411611.,+Revision+1~Chapter~UNIT+GROUP+4116+Massage+Therapists

I am selecting and copying the code directly from the website.
Sometimes I am accidentaly also copying a space after the numbers.

Afterwards in Excel I use concatenate to create a list of commands,
e.g. replace anzscovariable=411611 if id==6  etc. Because the space
after the massage therapist code is now also getting incorporated
getting copied this is what is creating the problem.

*Short answer
 I am copying numbers from the web, pasting them into excel,
generating the commands, and then pasting them into a do-file and thus
probably introducing the bad characters in the process.


On Wed, Oct 17, 2012 at 4:57 AM, Nick Cox <> wrote:
> I believe you, but I see nothing different. I guess that others will
> see what you see if and only if their mailer behaves like yours.
> But the more tools there are to spot this kind of thing, the better.
> Laura is signalling that your mailer may make odd characters evident.
> The same is true of many good text editors.
> Nick
> On Tue, Oct 16, 2012 at 6:14 PM, Laura Gibbons
> <> wrote:
> > I know the problem has been solved, but I just wanted to note that in my
> > DOS-based email client, the problem is obvious (see how it displays below).
> >
> >
> > On Tue, 16 Oct 2012, Anna Reimondos wrote:
> >
> >> Hello statalisters,
> >> I am currently coding occupations of respondents in a survey to the
> >> Australian New Zealand Standard Classification of Occupations
> >> (ANZSCO).
> >> A rather odd thing is happening where I am able to assign the ANZSCO
> >> code in some cases, but not others!
> >>
> >>
> >> For example in the code below there is no problem assigning the value
> >> 121312 to case 1, and no problem assigning the value 121314 to case 2.
> >> However for case 3 who I want to give the code 121313 the code returns
> >> an error message '121313 invalid name' r(198).
> >>
> >> clear
> >> set obs 3
> >> gen var1=.
> >> replace var1=121312 if _n==1
> >> replace var1=121314 if _n==2
> >>
> >> replace var1=121313 if _n==3  //Problem
> >>
> >> The problem is not just with 121313, but it also does not seem to like
> >> 254499, 323112 and 821311 among others.
> >> I don't understand what is happening!
> >>
> >> I am using Stata 12.1, but have also tried this in 11.2 and get the
> >> same error code.
> *
> *   For searches and help try:
> *
> *
> *
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index