Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: add zero to values of variable


From   "Sebastian F. B�chte" <[email protected]>
To   [email protected]
Subject   Re: st: add zero to values of variable
Date   Sat, 3 Jun 2006 16:44:18 +0200

Raoul,

depending on what you would like to achieve, you can either follow
Rosy's suggestion which will change a 12 into a 120,or, if your
question aims at adding leading zeros and if your variable is a
numerical one, you could use a leading zero display format. The latter
will not change the values of your variable but has an effect whenever
you display values of the variable . The command could look like this:

format %03.0f your_variable

Regards,
sebastian

On 6/3/06, raoul reulen <[email protected]> wrote:
Hi,

I have a variable  which has 2-digit values and 3-values. I would like
to change all 2-digit values into 3 digits  by adding a zero. How can
I do this? Thanks.

Raoul
see example below

the list of values looks like this:

12
148
456
21
364
390

and I would like to add a zero to the third and fourth values.
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index