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

st: Is there a command that returns a Variable's Type?


From   "Orion Whitaker" <owhitak1@jhmi.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Is there a command that returns a Variable's Type?
Date   Sat, 30 Apr 2005 20:23:54 -0400

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




--
Orion C. Whitaker
Johns Hopkins School of Public Health
Johns Hopkins School of Medicine
owhitak1@jhmi.edu
*
*   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