Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Removing space from string variable


From   "Dimitriy V. Masterov" <[email protected]>
To   [email protected]
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 <[email protected]> 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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index