Statalist


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

Re: st: numeric to string - transform from 1 to 01?


From   David Kantor <kantor.d@att.net>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: numeric to string - transform from 1 to 01?
Date   Thu, 06 Sep 2007 09:44:35 -0400

At 09:30 AM 9/6/2007, Franco wrote:
Hi,

I have a numeric variable, "ind" which goes from 1 to
20.

I want to convert it into a string variable "indstr",
that goes from 01 (as opposed to 0) to 20.

How can I achieve this?
Try,
tostring ind, gen(newvar) format(%02.0f)

Note the use of the format option, and the leading-zero format.
See -help tostring- and -help format-.
--David

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index