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

st: RE: RE: RE: RE: eliminating the nth digit of a numeric variable


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: RE: eliminating the nth digit of a numeric variable
Date   Thu, 27 Feb 2003 16:32:46 -0000

Nick Cox
> 
> Zero fill is unnecessary, even this route.
> 
> The last two characters are
> 
> substr(string(myvar),-2,2)
> 
> The first substring wanted is
> 
> substr(string(myvar),1,length(string(myvar))-3)
> 
> The whole is thus
> 
> substr(string(myvar),-2,2) +
> substr(string(myvar),1,length(string(myvar))-3)
> 
> and the numeric equivalent is
> 
> real(substr(string(myvar),-2,2) +
> substr(string(myvar),1,length(string(myvar))-3))
> 
> Not tested.

Not only not tested, but wrong in that 
the order of the substrings should be reversed. 

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