Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Sample command question

From   Richard Williams <>
Subject   RE: st: Sample command question
Date   Sun, 29 Oct 2006 21:22:19 -0500

At 09:10 PM 10/29/2006, David McClintick wrote:
Actually, I just realized that your suggestion isn't going to work. As I
am generating a sample based on each variable, and I have different
amounts of missing values for each variable, your command would drop all
observations that had any missing value for any one of the variables. I
only want to drop observations for that particular sample when missing
in that particular variable.
All the loops sort of confuse me so you may be right! But I guess I don't see how that happens if the code is something like

local i=1
foreach x in var1-var91 {
while `i' <=10 {
use c:\ado\personal\easy.dta
keep if !missing(`x')
sample 5, count
save mewsample`i', replace
local i= `i' +1

You open a file, drop cases with MD on 1 variable, sample and save as a new file, and then reopen the original file and repeat the process for a total of 10 times, and then move on to a different x.

In any event, I am guessing that some sort of keep if statement should be in there, even if I don't have the right one.

Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: Richard.A.Williams.5@ND.Edu
WWW (personal):
WWW (department):
* For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index