I suggest reading through the folling FAQs:
http://www.ats.ucla.edu/stat/stata/faq/regex.htm
Then: trial and error.
Good luck.
Florian
-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Kuma Raj
Gesendet: Montag, 5. November 2012 12:05
An: statalist@hsphsun2.harvard.edu
Betreff: st: Extract parts of a string variable
I have a messy string variable that contains names of various air pollutants. The contents and naming is based on the name of the pollutant, lags, station name, and different exposure metrics. There is no uniformity or fixed position of the contents in the variable name. I am interested to parse the variable and extract the names of the pollutants if they are specific strings. How can I do that ?
A sample of the variable is found below and I am interested to extract the following strings:- co, no2, nox, o3, pm10, and pm25
L1comeanH10
L1comeanS10
no2T10
L1no2T10
L1noxT10
L1o3maxA10
comeanS10_01
L3o3maxM10
L1o3meanM10
L1o3maxT10
L2pm10T10
L1pm25T10
Thanks in advance
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/