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: Unable to use "replace" on specific values (but others work ok)
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: Unable to use "replace" on specific values (but others work ok)
Date
Tue, 16 Oct 2012 02:16:52 +0100
Thanks for the report. I am in no sense a hardware expert but I wonder
whether you have a defective keyboard.
Note the use of -filefilter- here.
. filefilter mystrange.do mynice.do, from(\160d) to(\032d)
Nick
On Tue, Oct 16, 2012 at 2:03 AM, Anna Reimondos <[email protected]> wrote:
> Thanks for all your help.
>
> Yes I can confirm that I wrote the comment because I was working from a
> do-file and just wanted to make it clear which line was the problematic one.
>
> Nick I think you are right about the extended characters again!
> I did a hexdump analysis of the do-file which said there were some 'bad'
> characters (160-254). I am not sure how they are creeping in as I have
> never had this problem before.
>
> Line-end characters Line length (tab=1)
> \r\n (Windows) 2,690 minimum 1
> \r by itself (Mac) 0 maximum 279
> \n by itself (Unix) 0
> Space/separator characters Number of lines 2,690
> [blank] 7,863 EOL at EOF? yes
> [tab] 25
> [comma] (,) 517 Length of first 5 lines
> Control characters Line 1 95
> binary 0 0 Line 2 13
> CTL excl. \r, \n, \t 0 Line 3 95
> DEL 0 Line 4 1
> Extended (128-159,255) 0 Line 5 1
> ASCII printable
> A-Z 248
> a-z 52,148 File format EXTENDED ASCII
> 0-9 24,944
> Special (!@#$ etc.) 9,513
> Extended (160-254) 8
> ---------------
> Total 100,646
>
>
> Anyhow I just tried I deleted the problematic lines, and just typed them
> all in again (perhaps not the most elegant solution of course) and it
> seemed to work!
>
> Thanks again!
>
> Anna Reimondos
>
> On Tue, Oct 16, 2012 at 11:49 AM, Justina Fischer <[email protected]> wrote:
>>
>> This happened also to me quite often and Nick's explanation was right in
>> my case (e.g. a space or the other sign do not see but that corrupts your
>> commands in the do-file).
>>
>> The eseaiest way to overcome this problem is to avoid copying command
>> lines, but to write them by hand instead each time.
>>
>> Justina
>>
>>
>> -------- Original-Nachricht --------
>> > Datum: Tue, 16 Oct 2012 01:09:52 +0100
>> > Von: Nick Cox <[email protected]>
>> > An: [email protected]
>> > Betreff: Re: st: Unable to use "replace" on specific values (but others
>> > work ok)
>>
>> > I can't reproduce your problem. However, if your do-file or command
>> > lines are corrupted by strange characters such as char(160) -- recall
>> > the previous thread you started -- you might get some very odd
>> > messages about invalid names. Use -hexdump- on a file containing
>> > commands.
>> >
>> > Also, you are using a -float- to contain large integers. That's bound
>> > to run into problems sooner or later, but not with the example values
>> > given here.
>> >
>> > . clear
>> >
>> > . set obs 3
>> > obs was 0, now 3
>> >
>> > . gen var1=.
>> > (3 missing values generated)
>> >
>> > . replace var1=121312 if _n==1
>> > (1 real change made)
>> >
>> > . replace var1=121314 if _n==2
>> > (1 real change made)
>> >
>> > . replace var1=121313 if _n==3
>> > (1 real change made)
>> >
>> > On Tue, Oct 16, 2012 at 12:36 AM, Anna Reimondos <[email protected]>
>> > wrote:
>> >
>> > > 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:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/