Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

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


From   "Dimitriy V. Masterov" <[email protected]>
To   [email protected]
Subject   Re: st: Confirming whether a variable is binary or continuous
Date   Fri, 16 Mar 2012 17:27:17 -0400

Bert,

tab saves the number of rows behind in r(r). You could create an
if-else loop where you do the prtest if r(r)==2 and ttest when not.

Probably not the most elegant way to do this.

DVM

On Fri, Mar 16, 2012 at 5:18 PM, Bert Jung <[email protected]> wrote:
> Dear Statalisters,
>
> 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?
>
> Thanks for any pointers,
> Bert
> *
> *   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/

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index