Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: ST: variable editing


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: ST: variable editing
Date   Wed, 25 Jun 2008 17:20:20 +0100

Not so. Friedrich's solution was 

. replace country = subinstr(country,"*","",.)

Not 

. replace country = subinstr(country,"*"," ",.)

Of course, there may have been a trailing blank to start with. 

In either case, as Bret points out -trim()- would take care of any
(leading or) trailing blanks. 

More generally, what one function doesn't do is often solved by another.


Nick 
[email protected] 

Eric Uslaner

Thanks Mike, Zhiqiang, and Friedrich for your help.  One other issue.
On either Zhiqiang's or Friedrich's solutions, the result for country
names with one or two asterisks is to delete the asterisks (as desired,
thanks), but to leave a trailing blank, so that:

Albania*

becomes

Albania_

where _ is not an underscore but simply a left-shifted blank that is not
the same as:

Albania

in another data set that I want to merge with this data set.

So when I do

mmerge country using otherdataset

and then sort _merge and clist _merge country

I get Albania in one data set and Albania_ in the second data set, with
the merged data set now having both, while they should be matched.  Any
help would be appreciated.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index