Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: warning: variable has embedded blanks


From   Eric Booth <ebooth@ppri.tamu.edu>
To   "<statalist@hsphsun2.harvard.edu>" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: warning: variable has embedded blanks
Date   Thu, 11 Aug 2011 15:37:34 +0000

<>

If by 'blanks' you mean 'spaces' then first take a look at -help trim-.  Sometimes blanks or spaces are other, invisible characters.  To find those I use a combination of -charlist-, -ascii- (or -asciiplot-) all user-written programs from SSC.  After installing these programs you can check for these characters with something like:

***********!
replace myvar = trim(myvar)
charlist myvar
di "`r(ascii)'"
ascii      //compare the char list with what should be there
**or:
asciiplot
**let's say, you found that your string included invisible char 20, then:
replace myvar = subinstr(myvar, "`=char(20)'" , "" , . )
************!
- Eric
On Aug 11, 2011, at 10:28 AM, Kwaku Damoah wrote:

> Dear Statalisters,
> Please can someone tell me how to remove embedded blanks from variables.
> Kwaku
> 
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index