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

st: RE: destring


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: destring
Date   Wed, 22 Jun 2005 21:16:08 +0100

If you make a string variable with leading 
zero into a numeric variable there is one, 
and only one, sense in which you can keep 
the leading zero. You can apply to it 
a format (e.g. %04.0f) that forces 
display with leading zeros. If you need
the leading zero for calculations or 
other manipulations then you need both 
string or numeric versions. 

Nick 
n.j.cox@durham.ac.uk 

Seyda G Wentworth

> I need to create a numeric variable (numvar) out of a string 
> (stringvar) to be able to say things like:
> 
> sum x y z if numvar==5
> 
> The string variable is a code  with values such as 0107, 
> 0256, etc. How can I make it numeric without loosing the "0" 
> in front? In other words I want to keep all the digits.

*
*   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