Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Generating a new var from last 11 character in a string


From   Roberto Ferrer <[email protected]>
To   Stata Help <[email protected]>
Subject   Re: st: Generating a new var from last 11 character in a string
Date   Sun, 15 Dec 2013 01:11:53 -0430

Use -substr- with a negative argument to get last characters :

substr("abcdef",-3,.) = "def"

See - help substr - for details.

On Sat, Dec 14, 2013 at 6:23 PM, lars Folkestad <[email protected]> wrote:
> Dear listers
>
> I want to do generate a new var from the last 11 character of a string variable. I normally count the possitions that i want and use the substring command, but my oldvar has contains different number of characters. The first position of interest maybe nr 1 in some observations and number 15 in others.
>
> Whats the best way to do this?
>
> Lars
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index