Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "Kwaku Damoah" <kdamoah@gmx.com> |
To | <statalist@hsphsun2.harvard.edu> |
Subject | RE: st: warning: variable has embedded blanks |
Date | Fri, 12 Aug 2011 06:40:35 -0000 |
Thanks Nick & Eric it has worked just fine Kwaku -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: 11 August 2011 17:56 To: 'statalist@hsphsun2.harvard.edu' Subject: RE: st: warning: variable has embedded blanks In addition to Eric's good advice, if the blanks really are just common or garden spaces " ", then . replace myvar = subinstr(myvar, " ", "", .) is the way to go, similarly to his bottom line. Nick n.j.cox@durham.ac.uk Eric Booth 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)'" , "" , . ) ************! On Aug 11, 2011, at 10:28 AM, Kwaku Damoah wrote: > Please can someone tell me how to remove embedded blanks from variables. * * 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/