Statalist


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

RE: st: RE: problems on the string functions


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: problems on the string functions
Date   Thu, 19 Nov 2009 23:48:18 -0000

gen v3 = v1 
qui forval i = 1/10 { 
	replace v3 = subinstr(v3, substr(v2, `i', 1), "", 1) 
} 

Nick 
n.j.cox@durham.ac.uk 

gjhxmu@sina.com

Thank you very much, Baum and Nick.
I understood the use of -subinstr-, -word- and -strpos- with your help.
Another problem is how to deal with it if the strings excluded from
another string variable is not consecutive.

for example,
clear
input str10 (v1 v2)
ab123d  12d
efg34  f4
end

I want to get v3 as followings
v3 
ab3
eg3


*
*   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   |   What's new   |   Site index