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" <[email protected]>
To   <[email protected]>
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 
[email protected] 
*
*   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