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

st: re: discerning a variable's "type"


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: discerning a variable's "type"
Date   Sun, 1 May 2005 15:08:35 -0400

Although Nick Cox is certainly correct in noting that a researcher's classification of a variable as "discrete" or "continuous" is not one of Stata's characteristics defining that variable, two things come to mind:

1) compress will turn a "false float" into an appropriate integer (but one may not want to routinely compress a data set just to find that out!)

2) a reasonable approximation to D vs C can be had with a minor mod of Phil Ryan's code:

webuse auto, clear
foreach var of varlist _all {
local ty : type `var'
if index("`ty'","str") == 0 {
capt assert `var' - int(`var') == 0 if `var' < .
local wh = cond(_rc>0,"Continuous","Discrete")
display " `var' " _col(20) "`: type `var''" _col(30) "`wh'"
}
}

price int Discrete
mpg int Discrete
rep78 int Discrete
headroom float Continuous
trunk int Discrete
weight int Discrete
length int Discrete
turn int Discrete
displacement int Discrete
gear_ratio float Continuous
foreign byte Discrete

Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html

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