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

st: Adding leading zeros to numeric variable and converting to string


From   Ankur Sarin <[email protected]>
To   [email protected]
Subject   st: Adding leading zeros to numeric variable and converting to string
Date   Sat, 17 May 2003 09:03:13 -0700 (PDT)

I need to convert a numeric variable to string but add
leading zeros. 
So a 4 needs to be converted to 004, a 40 to 040 and
400 to 400 (only  upto 3 digits). I need to combine
this new string variable with another to make ids. 
I tried
tostring hhpsu, f(%03s)
 but that returns hhpsu as str1 and with all missing
values. 
Thank you for your time and help.
             -Ankur


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
*
*   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