Statalist The Stata Listserver

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

st: Re: how to drop to get a balanced panel

From   "Michael Blasnik" <>
To   <>
Subject   st: Re: how to drop to get a balanced panel
Date   Sat, 19 May 2007 13:08:43 -0400

Here's one way:

egen nmiss=rmiss(bodyweight var2 var3 var4)
bysort id (nmiss): drop if nmiss[_N]>0

The first command counts the number of missing values across the variable list of interest for each observation. The second command sorts by id and then number of missing values and drops the entire id if there are any missing values (by checking the maximum number of missing values for that id).

Michael Blasnik

----- Original Message ----- From: <>
To: "statalist" <>
Sent: Saturday, May 19, 2007 12:30 PM
Subject: st: how to drop to get a balanced panel

Dear users,

I have an unbalanced panel of students ("id" = 1, 2, ..., 5040), from 1998 to 2002 ("time"), and a number of variables (ex. body weight...). I need generate a complete panel dataset, by eliminating every student for which there is at least a single item data missing for a year (or more). Could you help me with an example? Thank you.

Damiano Rossi
*   For searches and help try:

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