Statalist


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

AW: st: RE: Converting a continuous var into a binary var


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   AW: st: RE: Converting a continuous var into a binary var
Date   Tue, 7 Jul 2009 00:14:14 +0200

<> 

So here is the code w/o line delimiters as I suspect they do cause problems
for some list users. Beginners might also be disappointed when pasting these
line delimiters interactively and getting error messages...


*************
clear*
set obs 10000

gen x=rnormal()
centile x, ce(10)
local p10x=`r(c_1)'

gen z=rnormal()
centile z, ce(10)
local p10z=`r(c_1)'

* get indicator y  
gen byte y=!(x<=`p10x' & z <= `p10z')
replace y=2 if x>`p10x' & z < `p10z'
replace y=3 if x>`p10x' & z > `p10z'

* check 
su x z, det
table y, c(min x max x min z max z freq) row
*************



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Pancho Villa
Gesendet: Montag, 6. Juli 2009 22:32
An: statalist@hsphsun2.harvard.edu
Betreff: Re: st: RE: Converting a continuous var into a binary var

On Mon, Jul 6, 2009 at 4:15 PM, Martin Weiss<martin.weiss1@gmx.de> wrote:
>
> <>
>
>
> Am I right that for y=2 the z value does not matter at all? That is what I
> take away from your description of the problem...

Oops, the last line was supposed to be:

y = 3 if x > 10th percentile of x & z > 10th percentile of z
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index