Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: RE: How to (almost) randomly reduce the number of observations?


From   "Buzz Burhans" <buzzb3@earthlink.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: How to (almost) randomly reduce the number of observations?
Date   Mon, 19 Apr 2010 16:09:38 -0600

Dimitrije,
Conceptually, could you do something like this, which drops a proportion of
the ids first, then restores all the observations for that id.  It should
get you more closer to the proportionate reduction you want in larger
datasets:


program drop tabid

program tabid, sortpreserve
tabulate id
end

clear
sysuse auto
g id = word(make,1)

count
tabid
preserve
contract id
l
set seed 10192010
drop if runiform()<.5
tempfile kept
save `kept'
restore
merge m:1 id using "`kept'"
keep if _merge==3
count
tabid



Buzz Burhans, Ph.D. 

Dairy-Tech Group
So. Albany, VT / Twin Falls ID

Phone: 802-755-6842
Cell: 208-320-0829
Fax VT: 802-755-6842
Fax ID: 208-735-1289

Email: buzzb3@earthlink.net

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Dimitrije Tišma
Sent: Monday, April 19, 2010 2:31 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: How to (almost) randomly reduce the number of observations?

Hi,

I would like to ask how to reduce number of observations randomly BUT
in a way that all observations are kept that are related to the person
who still in the dataset. Thanks!

Dimitrije
*
*   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   |   Site index