Frank de Libero and Phil Ryan posted good
answers on the construct
: type <varname>
but the question posed in terms of continuous
vs discrete remains.
At worst, the discussion between continuous
and discrete is yours, not Stata's. Discrete
variables might be stored as doubles, longs,
floats, ints, or bytes. I can even imagine
something I regarded as essentially continuous
(e.g. income in dollars) being held as an int
or long if the values all turned out to be integers.
In addition to the construct mentioned, -ds-
allows a filtering on variable types _before_
you enter a loop.
Nick
[email protected]
Orion Whitaker
> I'd like to do different tests depending on a variables type
> (continuous
> vs discrete).
>
> While "codebook" displays "units" that would give me a clue (1 for
> discrete, 0.1 & 0.01... for continuous) I can't seem to find a command
> or function that would give me a variable's type.
>
> Something like: uses(varname) returning 1 or 0.1 or 0.01...
> or type(varname) returning "byte"
> "int" "double"...
>
> I imagine doing something like:
>
> foreach v of varlist var1 var2 var3... {
> if ( type(`v')==0 ) {
> do some discrete tests
> }
> else {
> if ( type(`v')==1 {
> do some continuous tests
> }
> }
> }
*
* 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/