Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: extract a subset of numbers from a bigger number


From   David Kantor <[email protected]>
To   [email protected]
Subject   Re: st: extract a subset of numbers from a bigger number
Date   Wed, 15 Sep 2004 13:38:39 -0400

At 10:30 AM 9/15/2004 -0700, Alejandro wrote:

How can I extract the last 5 digits a 9-digit number
(say a social security number) creating a new variable
?

i.e.

X                  newvar
999912345 --->     12345

[...]

Try this:
gen long newvar = mod(X, 100000)

-- David


David Kantor
Institute for Policy Studies
Johns Hopkins University
[email protected]
410-516-5404

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