Thank you so much.. not that hard after all..
On Wed, Mar 18, 2009 at 1:37 PM, Maarten buis <[email protected]> wrote:
>
> --- On Wed, 18/3/09, moleps islon <[email protected]> wrote:
>> -Is there an easy way to draw 40 random patients from a
>> sample of 450 and generate a dummy variable containg 0 "not
>> drawn" 1"drawn". E.g a command like : draw variable 40,
>> gen(dummy)
>
> When you want to create a dummy you implicitly assume that
> you want to draw without replacement. There is an easy way
> of doing this with replacement (as this is part of the
> bootstrap): -bsample- with the -weight()- option. If you
> realy want to sample without replacement you can adjust
> the code below:
>
> *---------- begin example ------------
> sysuse auto, clear
>
> // sort will store the original sort order
> gen long sort = _n
>
> // create your draw variable where you
> // sample 40 respondents (cars) without
> // replacement
> gen u = runiform()
> sort u
> gen byte draw = _n <= 40
>
> // restore the orginal sort order
> sort sort
>
> // clean up
> drop u sort
> *---------- end example ---------------
> (For more on how to use examples I sent to the Statalist, see
> http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )
>
> -- Maarten
>
> -----------------------------------------
> Maarten L. Buis
> Institut fuer Soziologie
> Universitaet Tuebingen
> Wilhelmstrasse 36
> 72074 Tuebingen
> Germany
>
> http://home.fsw.vu.nl/m.buis/
> -----------------------------------------
>
>
>
>
> *
> * 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/