Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Confirming whether a variable is binary or continuous |

Date |
Fri, 16 Mar 2012 22:30:32 +0000 |

-distinct- is also from SJ. The paper SJ-8-4 dm0042 . . . . . . . . . . . . Speaking Stata: Distinct observations (help distinct if installed) . . . . . . N. J. Cox and G. M. Longton Q4/08 SJ 8(4):557--568 shows how to answer questions about distinct observations from first principles; provides a convenience command is in effect a review of this and related questions. Nick On Fri, Mar 16, 2012 at 9:28 PM, Eric Booth <eric.a.booth@gmail.com> wrote: > One way is to -tabulate- the var and then use stored value in r(r) to tell how many values it has. You could also grab values from the user-written packages -egenmore- (form SJ, see the nvals() fcn) and -distinct- (from SSC) > > > Example: > > ********* > > sysuse auto, clear > > ds, has(type numeric) > foreach x in `r(varlist)' { > quietly tabulate `x' > if r(r) == 2 di in red `"`x' is binary"' > if r(r)!=2 di "`x' is not binary" > } > ********* On Mar 16, 2012, at 4:18 PM, Bert Jung wrote: >> I am writing a short program to make a balance table that compares >> covariates across a treatment and control group. I am looking for a >> way to confirm whether a variable is binary in order to use -prtest- >> for proportions rather than -ttest- for continous variables. >> >> One option is to check the actual data values and do -prtest- if there >> are only 0's and 1's. But a continuous but rare outcome could >> accidentally also take these values, e.g. the number of >> hospitalizations in the past 3 months. >> >> Is there a safer way to confirm that a variable is binary? * * 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/

**References**:**st: Confirming whether a variable is binary or continuous***From:*Bert Jung <bjung59@gmail.com>

**Re: st: Confirming whether a variable is binary or continuous***From:*Eric Booth <eric.a.booth@gmail.com>

- Prev by Date:
**Re: st: Confirming whether a variable is binary or continuous** - Next by Date:
**Re: st: Confirming whether a variable is binary or continuous** - Previous by thread:
**Re: st: ztnb model: why are some results omitted?** - Next by thread:
**Re: st: Confirming whether a variable is binary or continuous** - Index(es):