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]

st: RE: remove special characters from string


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: remove special characters from string
Date   Tue, 2 Nov 2010 20:00:57 +0000

Intuition is the weaker part of documentation. See the -help- on -functions-, particularly string function. 

If they are just ..- then 

replace oldstring = subinstr(oldstring, ".", "",.) 
replace oldstring = subinstr(oldstring, "-", "",.)

should do it. 

If the characters are exotic, then -charlist- from SSC is a utility to find out what they are. 

Nick 
[email protected] 

Skipper Seabold

I'm trying to use reshape with a string variable, but my string
variable contains special characters.  Is there a way (ideally without
using mata) to do something like (intuitively)

gen str6 newstring = string(oldstring), ignore(".-")

Ie., I have data that looks like

oldstring

A.X.B-2
A.X.B-3
A.X.B-2
A.X.B-3

I would ideally just like to create

AXB2
AXB3
AXB2
AXB3

Or should I just use a scripting language to preprocess...


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