Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: Fwd: getting part of strings


From   Daniel Marcelino <dmsilva.br@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Fwd: getting part of strings
Date   Sat, 26 Mar 2011 13:48:35 -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/


© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index