Wednesday, March 08, 2006
st: RE: string function
This is hard to do in an error-free way, at least without knowing more details.
You can use -destring- with the -ignore()- option to get rid of alphabetic and punctuation characters, but don't lose periods.
Alternatively, if the number is always followed by a space, as is good scientific practice, then what you want is just the numeric version of the first word. Look at -split-.
Andy Choi > I have a large file with patient's labs. The lab > variable contains the lab result (a number) with the > units (for example mg/dl) included. There are many > variations to the way the units are reported: they may > be capitalized or in parentheses or the units > themselves may contain numbers. > > I would like to create a variable that includes only > the lab result. And if possible a separate variable > with the units.
* * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/
Links to this post: