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: Removing space from string variable


From   "Dimitriy V. Masterov" <dvmaster@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Removing space from string variable
Date   Thu, 12 Apr 2012 18:16:15 -0400

Mike,

You might be able to see what the weird characters are using hexdump
with the analyze option, and remove them with the filefilter command.
However, you might have to save the excel file as csv or txt file
first.

DVM

On Thu, Apr 12, 2012 at 6:08 PM, Mike Kim <kalisperos@gmail.com> wrote:
> Hi all,
>
> I have a question about removing leading and trailing spaces.
>
> I imported excel file:
> import excel using “myfile.xlsx”, first clear
>
> Some observations of the variable “brand” have leading or trailing
> spaces. Stata reads some spaces as spaces. In this case I can remove
> spaces using:
> replace brand=trim(brand)
>
> The problem is that Stata reads some spaces as “?”. In this case, trim
> does not work. More strange thing is that on screen of data editor,
> Stata shows “?” like the following, but if I double click, neither a
> space or “?” is not there. Stata still recognize the two as different
> observations.
>
> Mercedes
> Mercedes?
>
> How can I remove “?” and make them as the same observations?
>
> Thank you.
> Mike.
>
> *
> *   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