Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: Swor and sample commands


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   st: Re: Swor and sample commands
Date   Thu, 22 May 2003 20:25:52 -0500

----- Original Message -----
From: "karoline mortensen" <[email protected]>
To: <[email protected]>
Sent: Thursday, May 22, 2003 10:12 AM
Subject: st: Swor and sample commands


> Hi,
>
> I would like to randomly select (without replacement) 5% of my data, and
> keep all the data that were not selected. I believe this rules out the
> Stata "sample" command, because that discards the 95% of observations that
> were not selected.
>
> In other analyses I have used the very useful "swor" command (which allows
> the option of keeping non-selected observations). However, now I want to
> randomly select 5% (not an absolute count) of my observations, by an ID
> variable, so 5% of each ID get selected. Swor seems to only allow an
> absolute count to be selected. Is there another option that allows me to
> randomly sample a certain percentage, while keeping all the observations
> in the dataset?
>
> Thanks in advance,
> -Karoline Mortensen
>
You could use -sample2-  (findit sample2 will bring up the file)

sample2 5, keep(varname)

Scott




*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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