Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: -charlist- revised on SSC; question about -*trim()-


From   "Renzo Comolli" <[email protected]>
To   <[email protected]>
Subject   Re: st: -charlist- revised on SSC; question about -*trim()-
Date   Sat, 30 Apr 2005 10:03:20 -0400

Actually, I faced exactly the same problem last week copying material from a
webpage. I can't guarantee that they were char(160), but for sure they were
spaces of a size different from the standard Stata size.
I also tried trim() and it did not work. I had not seen the discussion, so I
did it all by hand. I don't quite remember exactly what I did because it
took me so little, but I think I copied the whole thing in Notepad, then in
Excel, then -insheet-

Renzo

----------------------------------------------------------------------------
----
*From   "Nick Cox" <[email protected]> 
To   <[email protected]> 
Subject   st: -charlist- revised on SSC; question about -*trim()- 
Date   Sat, 30 Apr 2005 12:37:42 +0100 

----------------------------------------------------------------------------
----

Daniel Egan started a thread by publicising 
a dataset in which a string variable that 
"should have been" numeric contained hard-
to-detect non-numeric characters. 

He eventually fixed his problem by editing 
the original data file within a text editor. 

He tried using, among others, the program 
-charlist- from SSC, but did not find it helpful. 

I then explained what had happened: the problem 
arose from occurrences of the non-breakable space, 
in Stata terms -char(160)-, which is hard to 
see when displayed at the end of a string. 

-charlist- had reported the occurrences nevertheless. 

What I have done is revise the help file for 
-charlist- adding and explaining this very 
interesting and instructive example. Kit Baum 
kindly replaced the file on SSC. You can 
install or replace -charlist- by 

. ssc inst charlist 

or 

. ssc inst charlist, replace 

Stata 7 is required, as previously. 

This leaves an open question about -trim()-. 
In both Stata 8 and Stata 9, something like 

. gen foo = "foo" + char(160) 

adds a character that -trim()- won't remove. 

. replace  foo = subinstr(foo, "`=char(160)'", "",.) 

will do it. But I'm tempted to regard it as a limitation
of -trim()- that it won't remove -char(160)-. 

-ltrim()- or -rtrim()- raise the same issue. 

On the other hand, Daniel's report is the first 
and only report of a problem I can recall of this 
kind. 

StataCorp may have a comment. 

Nick 
[email protected] 



*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index