Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: extract middle of string


From   Ronnie Babigumira <[email protected]>
To   [email protected]
Subject   st: extract middle of string
Date   Tue, 24 Oct 2006 16:30:54 +0200

I have a string variable that looks like this

x
161011000AT
161011000CN
1610110012CN


I am interested in what lies between the first and the last two characters

I could have used

gen str10 = subst(x, 2, 8) but that would not work for the last observation. How can I simply drop the first character, and last two charters in x

*
* 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/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index