Statalist The Stata Listserver

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

Re: st: extract middle of string

From   "jean ries" <>
Subject   Re: st: extract middle of string
Date   Tue, 24 Oct 2006 16:47:01 +0200

This should do the job:

gen newx = substr(x,2,length(x)-3)

On 10/24/06, Ronnie Babigumira <> wrote:
I have a string variable that looks like this


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:

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