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: Dropping last digit Stata


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Dropping last digit Stata
Date   Sat, 29 Jun 2013 12:40:40 +0100

If your variable is string

gen wanted = substr(existing, 1, 8)

If your variable is numeric

gen long wanted = floor(existing/10)

Nick
[email protected]


On 29 June 2013 12:25, Lok <[email protected]> wrote:

> I'm trying to delete the last digit of a variable. Right now the variables have 9 digits like: 12345678x with x being a number between 1 and 9. I would like it to be 12345678.
>
> As a beginner to Stata, I was wondering if anybody could please offer some help.
>
> I'm using Stata 12SE on OS X.
*
*   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