Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

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


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Confirming whether a variable is binary or continuous
Date   Sat, 17 Mar 2012 07:46:20 +0000

My wording was sloppy. That test is satisfied also by one distinct
value. For there to be precisely two distinct values, it is also
necessary for -var[1]- to differ from -var[_N]-.

Similarly the test -inlist(var, 0, 1)- is satisfied if -var- is always
0 or if -var- is always 1.

Nick

On Sat, Mar 17, 2012 at 7:05 AM, Nick Cox <njcoxstata@gmail.com> wrote:
> Variations on this are often used inside Stata commands
>
> sort var
> assert var == var[1] | var == var[_N]
>
> Here -var- must be one of two distinct values, but nothing specifies
> what they are precisely.
>
> Nick
>
> On Fri, Mar 16, 2012 at 11:39 PM, daniel klein
> <klein.daniel.81@googlemail.com> wrote:
>> Nick,
>>
>> very smart solution, thanks. Seems it is often the simple solutions
>> that are so hard to find.
>>
>> The difference to the "-tabulate- solution" is that <var> is allowed
>> to be a constant here, which is perfectly alright for a binary
>> variable. It is for Bert to decide whether the indicators are allowed
>> to be constant or have to vary.
>>
>> Daniel
>>
>> --
>> You can also do this by e.g.
>>
>> assert inlist(var, 0. 1)
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index