[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: RE: Leading Zero's
Alexander Quarshie, MD, MS
> Does anyone know a quick way in STATA to add leading zeros
> to a numeric variable (even if I have to convert it to a
> string, that would be okay).
> A typical example might be to convert the following numbers
> to a standard five-digit number with leading zeros:
> 2 --> 00002
> 33 --> 00033
> 473 --> 00473
> 59724 --> 59724
Display with leading zeros is a matter of format.
di %05.0f 2
A more fundamental change is
gen str5 s_foo = string(foo,"%05.0f")
. search leading zero
points to an FAQ
so all this is one command line away in Stata.
* For searches and help try: