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: getting part of strings
From
Daniel Marcelino <[email protected]>
To
[email protected]
Subject
st: getting part of strings
Date
Sat, 26 Mar 2011 14:05:31 -0300
Dear all,
I'm dealing with a large data set which one string var is completely
nested. I easily take off numbers from it, but I still breaking my
head trying to figure out how can I get from var words like "PP",
"Deputado Federal", "Senador", "Deputado Estadual". So, below a paste
few cases.
clear
inp str200 var1
"155 - VITAL DO REGO FILHO - PB - Senador"
"1111 - - PP - - Deputado Federal / 25888 - ATAIDES MENDES PEDROSA -
PB - Deputado Estadual"
"1111 - - PP - - Deputado Federal / 22333 - EDNALDO PEREIRA DE
SANTANA - PB - Deputado Estadual"
"151 - JOSE WILSON SANTIAGO - PB - Senador"
"45123 - ANTONIO HERVAZIO BEZERRA CAVALCANTI - PB - Deputado Estadual"
"1212 - DAMIÃO FELICIANO DA SILVA - PB - Deputado Federal"
end
gen var2 = regexs(0) if regexm(var1, "^[0-9a-zA-Z]*")
*
* 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/