Given the specific problem at hand, it seems to me that replacing the LAST
zero could be pretty hazardous. One would need to do a frequency of the
last digit, the second to last digit, and the third to last digit to be
POSITIVE that there is not a zero in a location that should stay there.
This is probably a good idea in any case.
But since the specific problem is to drop the zero that is in the third to
last position, a solution that does only that seems preferable.
Bryan Sayer
Statistician, SSS Inc.
[email protected]
-----Original Message-----
From: Bill Rising [mailto:[email protected]]
Sent: Thursday, February 27, 2003 12:39 PM
To: Stata Listserve
Subject: RE: st: RE: eliminating the nth digit of a numeric variable
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/
*
* 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/