Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: How to lengthen a number


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: How to lengthen a number
Date   Wed, 10 Feb 2010 19:48:55 +0100

<>

*******
clear*
inp x
12345
end
gen strx="0"+string(x)
l
*******


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nathan Hutto
Sent: Mittwoch, 10. Februar 2010 19:37
To: statalist@hsphsun2.harvard.edu
Subject: st: How to lengthen a number

Hi all,

I have a numeric variable "x". Some of the values are 5 digits and
others are 6 digits. I would like all of the values to be 6 digits, so
I would like to add a zero to the beginning of the 5 digit values. I
converted "x" to a string variable, created another string
variable=="0" and added them together, but that didn't work. Anyone
know how I can do this?

thank you,
Nathan
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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