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]

RE: st: Generating missings/dropping specific data based on one variable

From   Nick Cox <>
To   "''" <>
Subject   RE: st: Generating missings/dropping specific data based on one variable
Date   Mon, 23 Apr 2012 11:07:55 +0100

In essence, you need -replace-, not -generate-. 


Ronnie Babigumira

Showing some data would help but anyway, here is an hypothetical example. 

Two variables, "howmuch" should only be answered by those who answered yes (1) in the variable "didsth"

id didsth howmuch 
1 1 82 
2 0 . 
3 0 6 
4 1 54 
5 1 92 
6 0 34 
7 1 .  

gen perror = didsth == 0 & howmuch !=.  // Or however you coded not applicable
gen truemis = didsth == 1 & howmuch ==.

If your interest is in real missing's (didsth is yes but you have no data on howmuch), then look at truemis. If you are looking for potential data entry errors, look at perror

On Monday, April 23, 2012 at 10:27 AM, Nina Bjerre Andersen wrote:

> I have the peculiar problem of having to generate missings:
> I have a dataset based on web-based questionnaire data, where some observations now include data on variables where they should be missing, i.e. some participants should not have been invited to answer those particular questions based on a "yes/no"-question given on another variable.
> I therefore wish to generate missings, but I am finding that
> - using -drop- I am only allowed to drop entire observations
> - using -mvdecode- I can only generate missings based on the value of the variable itself.

*   For searches and help try:

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