On 2/27/03 8:11, Nick Cox wrote
>Sanz De Galdeano, Anna
>>
>> I have a numeric variable which takes, for instance, values like:
>>
>> 1017
>> 273076
>> 518097
>> 3046
>>
>> As you see, all these numbers have one thing in common: the
>> third difit
>> starting from the right is always 0. That 0 should not be
>> there and I want
>> to get rid of it so that my numeric variable looks like:
[the good solution using mod and int...]
Nick also gave a solution for replacing all 0's:
>
> real(subinstr(string(myvar),"0","",1))
>
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)
Bill
*
* 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/