Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: Mark observations with missing data

From   Richard Herron <>
Subject   st: Mark observations with missing data
Date   Fri, 6 Jan 2012 13:00:45 -0500

I learned about -dropmiss- (Stata Journal) from this Stata List post:

But I would like to keep all observations and just mark the ones with
missing observations in a given -varlist-. This way with an -if-
statement I can find summary statistics for the same data that I will
later use in regressions. I provide a hackish solution below, but is
there a better way? Is there anything flawed with my approach? I am a
little wary of loops and my own coding. Thanks!

Here is my hackish solution if I want to mark observations with any
missing variables.

* begin code
sysuse auto, clear
replace price = . in 1
replace mpg = . in 2
list in 1/5

* hackish solution
generate byte complete = 1
foreach x of varlist * {
    replace complete = 0 if missing(`x')
list in 1/5
* end code
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index