Dear all,
I have searched on the Forum for quite some time and tried different approaches to manipulating a quite messy and long string. I would appreciate any help in answering my question.
I have a variable labelled "infringement" that contains a lot of text (see two examples below):
infringement
Destruir (danificar, desmatar) florestas ou demais formas de vegetações consideradas de preservação permanente (áreas do art. 2º da Lei 4.771/65)
Ficam embargadas todas e quaisquer atividades em uma área 26,823 hectares, delimitada pelas coordenadas geográficas constantes no processo administrativo correspondente.
My question is how can I extract only the number of hectares (as highlighted in red in the second example) using Stata 17?
My thought was to drop everything after hectares (including the word hectares) and then keep the numerical values that indicate the number of hectares from the end of the remaining string until the next whitespace. Note that the length of the unit of hectares can vary and that the number might be interrupted by a comma or dot. I want the full number saved as a string as I intend to subsequently destring the variable separately (i.e., although the comma should separate decimals in this dataset, it is quite messy: I find that commas and dots are likely used interchangeably).
I hope someone can help!
Thanks a lot.
Sandra
Related Posts with Manipulate complex long strings - Drop everything after word "hectares" and keep number of hectares
How would you export ANOVA tablesforeach var in Subclass { anova ATF4Targetgenes `var' export ?????????? } Hello everyone, I have c…
Criteria to apply xtpcseHello everyone. I have a dataset with N = 178 and T =14 . Is it right to go for panel corrected stan…
Questions about pseudo-strata/psu in complex survey designHi: This is not a stata related question, so please forgive me if this is not allowed. I am dealin…
Storing the value of a variable from one observation in a local macro or scalarDear Statalist, I'm using Stata 16.0 trying to store a variable value from one observation in a loc…
Collapse variables by country, category, yearHi! I have the following data (dataex below) and I just want to confirm if I am doing the right app…
Subscribe to:
Post Comments (Atom)
0 Response to Manipulate complex long strings - Drop everything after word "hectares" and keep number of hectares
Post a Comment