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

Re: st: -trim()-ed but cannot -destring()-:- hidden text characters?


From   Roger Newson <[email protected]>
To   [email protected]
Subject   Re: st: -trim()-ed but cannot -destring()-:- hidden text characters?
Date   Tue, 26 Apr 2005 16:03:01 +0100

At 15:07 26/04/2005, Dan wrote:
Hello list,

I am having a strange problem converting strings into numerical
format. I have a string which by all appearances is just a number. I
used trim() to make sure there weren't any hidden spaces, and then
attempted to -destring- again but with no luck. Trim indicates that
there weren't any changes made upon -trim-ing again...


If I -destring, force- I do get missing values for the majority of
values which appear to be trimmed numbers.

the file is at:
http://www.geocities.com/verbosemonkey/stata/sonj.zip

*****************************
foreach var of varlist _all {
replace `var'=trim(`var')
}
destring rank, replace
destring rank, gen(nrank) force
tab rank if nrank==.
****************************


Are there other "hidden" characters which could be preventing
-destring- which I can erase?
There definitely seem to be in my copy. If you -list- this dataset, then you see numerous question marks, which are probably hidden characters, and also a lot of "/" characters.

The -char()- function might be useful here for erasing these (once you know what they are), together with the -subinstr()- function. See -whelp functions-.

Hope this helps.

Roger



--
Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
Division of Asthma, Allergy and Lung Biology
King's College London

5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605
Email: [email protected]
Website: http://phs.kcl.ac.uk/rogernewson/

Opinions expressed are those of the author, not the institution.

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