Thanks in advance for your time and help. I have the following problem....Some of the data I received has all the ages of individuals as a string variable, with some ages of children specified as X Months or Z Yr and X Months. I would like to extract the number of months, so just X, from ages reported as X months and I would like to extract years and months together into a single number with a decimal between them. For example:
- 6 Months extracted as 6
- 1 Yr 2 Months extracted as 1.2
- gen age_num = ustrregexs(0) if ustrregexm(age, "(^[0-9]+)(\s)([Months])")
0 Response to How can I extract a portion of a string variable using regular expressions?
Post a Comment