Statalist


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

Re: st: draw a sample from variables and incidence rates


From   Alan Neustadtl <[email protected]>
To   [email protected]
Subject   Re: st: draw a sample from variables and incidence rates
Date   Wed, 18 Mar 2009 08:33:19 -0400

One solution is to create a variable containing a random, sort by this
variable and mark the first 40 cases,  The following code shows one
way to do this, but it can be made shorter.

Best,
Alan

/***********************************
sysuse auto, clear

gen id=_n

set seed 3182009
gen takesmp=runiform()

sort takesmp

gen takeflag=0
replace takeflag=1 if _n<=40

sort id
list id takesmp takeflag

drop id takesmp
**********************************/


On Wed, Mar 18, 2009 at 8:18 AM, moleps islon <[email protected]> wrote:
> Dear statalisters,
> 2 questions:
> -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)
> -How can i compare an exposed group to a non-exposed group when I have
> the number of cancer incidents in the exposed group, follow-up time
> and only adjusted incidence rates for the non-exposed group ? E.g 11
> cancers in 217 exposed subjects with a total follow-up time of 2500
> years compared to the adjusted incidence rate of 6/100000.
>
> Regards
>
> Moleps
> *
> *   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