Statalist


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

st: RE: Changing property of a variable into number


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Changing property of a variable into number
Date   Thu, 4 Sep 2008 13:33:57 +0100

You really need to do some reading on Stata basics! For example, as a
person working with medical data working through Svend Juul's book would
be excellent for you. 

The format %9s is a string format. It implies that the variable is a
string variable. Thus Stata won't let you change the format to a numeric
format. 

Even if Stata let you do that, changing how a variable is displayed does
not change how a variable is stored. 

You need to convert this variable to a numeric variable using
-destring-. 

See for a tutorial on numeric and string 

SJ-2-3  pr0006  . . . . . . . . . . . . Speaking Stata: On numbers and
strings
        Q3/02   SJ 2(3):314--329                                 (no
commands)
        explains the use of numeric and string data types in Stata
        and how to convert from one kind to another

You can find that on-line as a .pdf regardless of whether you or your
institution subscribe to the Stata Journal. 

Nick 
[email protected] 

Ziad El-Khatib

For strange reasons one of the variables (diarr) (coded 1/2) has
format %9s so I can not use it when putting it in a sum formula in
STATA.
I tried to change its format using edit command, I looked at another
variable format it has property %8.0g so I tried using it for diarr
variable but it gives window with message "%8.0g is not a valid
display format".

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