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

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


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

Bill Rising

> Nick also gave a solution for replacing all 0's:
> 
> >
> >	real(subinstr(string(myvar),"0","",1)) 
> >
> 

This replaces the _first_ zero found. 

> If it were known that the last zero were the evil zero, 
> this could be 
> done via:
> 
> real(reverse(subinstr(reverse(string(myvar,%30.0g)),"0","",1)))
> 
> (at least if the number is smaller than Stata's longs)
> 

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