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" <[email protected]>
To   <[email protected]>
Subject   AW: st: RE: Converting a continuous var into a binary var
Date   Tue, 7 Jul 2009 13:58:33 +0200

<> 

" I'm still struggling with how to loop a procedure"

What do you mean here? You would probably benefit from Nick`s
http://www.stata-journal.com/sjpdf.html?articlenum=pr0005




HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Pancho Villa
Gesendet: Dienstag, 7. Juli 2009 13:47
An: [email protected]
Betreff: Re: st: RE: Converting a continuous var into a binary var

Thank you, Martin and Howard.  I guess the main thing I learned is how
to define and invoke local variables.  With no background in
programming, I'm still struggling with how to loop a procedure.  Good
thing copy and paste exist.

On Mon, Jul 6, 2009 at 6:14 PM, Martin Weiss<[email protected]> wrote:
>
> <>
>
> 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: [email protected]
> [mailto:[email protected]] Im Auftrag von Pancho Villa
> Gesendet: Montag, 6. Juli 2009 22:32
> An: [email protected]
> Betreff: Re: st: RE: Converting a continuous var into a binary var
>
> On Mon, Jul 6, 2009 at 4:15 PM, Martin Weiss<[email protected]> 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/
>

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index