Statalist


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

Re: st: how to remove symbles or some part from a string?


From   "Michael I. Lichter" <[email protected]>
To   [email protected]
Subject   Re: st: how to remove symbles or some part from a string?
Date   Tue, 19 May 2009 01:42:32 -0400

If all of your strings are literally "(" + "name" + ")" with no spaces at beginning or end, then, assuming that country is defined as str20 ...

gen str20 new = substr(country, 2, strlen(country) - 2)

-ml

qingf wang wrote:
If I have "(...)" in a variable, how to remove it?  Thanks a lot!

Example:

country    new

(germany)  germany
(USA)      usa
(India)    India


*
*   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/

--
Michael I. Lichter, Ph.D. <[email protected]>
Research Assistant Professor & NRSA Fellow
UB Department of Family Medicine / Primary Care Research Institute
UB Clinical Center, 462 Grider Street, Buffalo, NY 14215
Office: CC 125 / Phone: 716-898-4751 / FAX: 716-898-3536

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index