See "help substr"
gen stuff=substr(var,8,4)
On Oct 13, 2009, at 11:05 AM, [email protected] wrote:
I need to extract year from a string variable (str24 %24s).
How can I extract, for example, 1998 from this observation:
Dec/17/1998 11:30:00 PM
Thank you.
*
* 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/
Bryce Mason, Ph.D.
Director of Institutional Research
Loyola Marymount University
1 LMU Drive | Los Angeles, CA 90045
b: 4823 University Hall
w: (310) 258-8838
f: (310) 338-1841
e: [email protected]
*
* 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/