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   Bill Rising <[email protected]>
To   "Stata Listserve" <[email protected]>
Subject   RE: st: RE: eliminating the nth digit of a numeric variable
Date   Thu, 27 Feb 2003 12:39:07 -0500

On 2/27/03 11:39, Nick Cox wrote

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

Oops. Wasn't reading too close.

Bill (redfaced)
*
*   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