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

st: RE: reduce a variables numbers of digits to 4 counting from left


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: reduce a variables numbers of digits to 4 counting from left
Date   Thu, 16 Jan 2003 14:56:18 -0000

Lassen, Peter,
 
> I have a numeric variable of 9-12 digits, of wich only the 
> first 4 digits counting from the left is of importance. I 
> therefore have to get rid of the remaining 5-8 digits.

gen y = real(substr(string(x),1,4)) 

Nick 
n.j.cox@durham.ac.uk 
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index