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]

st: Removing space from string variable


From   Mike Kim <kalisperos@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Removing space from string variable
Date   Thu, 12 Apr 2012 17:08:55 -0500

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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index