Monday, September 26, 2016

Stata Substring Search [Data]


To search for a substring in your string variables, the syntax for the conditional is:
if regexm(variable,"search-string")
For example, if you are looking for "ondas" in the auto database:
sysuse auto
l if regexm(make,"ondas")
Note that the string can take regular expressions. I.e., the following returns results where the make starts with "A" or "H"