On Dec 24, 2008, at 1:24 PM, [email protected] wrote:
I'm trying to extract the first number after a hyphen. For example,
from x="1234-1" I want to create y=1.
gen y = regexs(1) if regexm(x,".*-([0-9]+)")
will work if the number after the hyphen is always a positive
integer. The same approach can be easily modified to accommodate
negative and/or decimal numbers (i.e., by modifying the regular
expression).
-- Phil
*
* 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/