Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Help with string problem


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Help with string problem
Date   Fri, 25 Aug 2006 16:13:23 +0100

"you" here presumably meaning Fred's collaborators. 

There is a home-grown -egen- function called -sieve()- 
in -egenmore- from SSC that could be used to keep 
alphanumeric characters only. 

Nick 
n.j.cox@durham.ac.uk 

Rafal Raciborski
 
> you could also use the clean() function in excel first, which removes 
> all nonprintable characters, before pasting into stata.

Fred Wolfe 

> > To see the difference, I used -outfile- and then examined the two 
> > -apatkey-s at the hexadecimal level in a text editor. The key 
> > variable that didn't merge contained HEX(AO) characters instead of 
> > Hex(20). Hex(A0) is also a "blank" character (a 
> "non-breaking space" 
> > in MS office). In HEX the code was "20 A0 A0 22" or space NB-space 
> > NB-space ". Somehow this must have been created in the Excel file 
> > that was sent to me.

> >> Someone sent me a list of IDs (apatkey)for participants 
> registered in our
> >> databank. They sent an Excel file (alas). I pasted it into 
> Stata and later
> >> used StatTransfer, both with the same result.
> >>
> >> What I did was to save the IDs sent to me. Then I -used- 
> my databank and
> >> merged the new data in. The problem was that the merge 
> didn't work as
> >> people with the same apatkey didn't merge. Tracing this 
> down, I found that
> >> the length of the merged variable was different from the 
> master variable.
> >> It would seem that there are hidden characters in the case where 
> >> _merge == 2.
> >>
> >> Questions. Does anyone know how to see those hidden 
> characters? Is this a
> >> known problem with the hated Excel?
> >>
> >> . replace apatkey=trim(apatkey)
> >> . l apat greger _merge length if index(apatkey, "CLE210928")
> >>
> >>         +-----------------------------------------+
> >>         |      apatkey   greger   _merge   length |
> >>         |-----------------------------------------|
> >> 28469. |    CLE210928        .        1        9 |
> >> 74437. | CLE210928           1        2       12 |
> >>         +-----------------------------------------+

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index