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

Re: st: destring

From   "Svend Juul" <SJ@SOCI.AU.DK>
To   <>
Subject   Re: st: destring
Date   Wed, 22 Jun 2005 22:17:16 +0200

Seyda wrote:


"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."


You can't really "keep" the digits in a numeric variable, but you can 

control how to display the values with -format-:

  destring strvar , generate(numvar)
  format numvar %04.0f


If strvar is "0007", numvar is 7, displayed as 0007 in a list.


Both these commands will do the same thing:

  summarize x y z if numvar==7

  summarize x y z if numvar==0007


Was that an answer to your question?




Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6 
DK-8000 Aarhus C,  Denmark 
Phone, work:  +45 8942 6090 
Phone, home:  +45 8693 7796 
Fax:          +45 8613 1580 

*   For searches and help try:

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