UCLA Academic Technology Services HomeServicesClassesContactJobs
Help the Stat Consulting Group by giving a gift             
Loading

Stata FAQ
Can I quickly see how many missing values a variable has?

This FAQ illustrates the nmissing and npresent commands which show you the number of missing, and number of non-missing values for your variables. The nmissing and npresent commands were written by Nicholas J. Cox and you can download them using findit nmissing (see How can I use the findit command to search for programs and get additional help? for more information about using findit).

Let's illustrate use of the nmissing and npresent commands using the high school and beyond data file we use in our Stata Classes.

use http://www.ats.ucla.edu/stat/stata/notes/hsb1, clear
(highschool and beyond (200 cases))
The nmissing command shows us that one of the variables, science, has missing data, and it has 5 missing values.  By contrast, the npresent command shows us the number of non-missing values for all of the variables in our data file. From this, we see all of the variables have 200 non-missing observations, except for science that has 195 non-missing observations.
nmissing

science         5

npresent

id            200
gender        200
race          200
ses           200
schtyp        200
prog          200
read          200
write         200
math          200
science       195
socst         200

For More Information

For more information on similar commands, see the help or reference manual about the summarize , inspect, and codebook commands.

How to cite this page

Report an error on this page or leave a comment

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California