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

st: eliminating the nth digit of a numeric variable


From   "Sanz De Galdeano, Anna" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: eliminating the nth digit of a numeric variable
Date   Wed, 26 Feb 2003 22:09:39 +0100

Dear Stata users,

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:

117
27376
51897
346

I think I could get what I want by using decode to transfor my numeric
variable into a string variable and then use some of the string functions
and/or some of the egen options for strings.
I guess (although I did not work it out) I could also use an algorithm. But
I have run into similar problems in the past and I would like to know
whether there is any stata routine that can be used (something similar to
what the string functions do, but for numeric varriables instead) to get the
desired result faster.

Thanks a lot in advance,

Best,
Anna
*
*   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