Search code examples
stata

Deleting missing values


I'm trying to clean my panel data set in Stata, which includes data on GDP growth rates for different countries over 5 years. I would like to delete all rows, which have missing values (denoted as .. in the data set). Each row has an id (gene row_id = _n). For example, if I want to delete all missing values of the variable YR2013, I use the code: drop if YR2013==. and the error message type mismatch appears. Can someone tell me how to delete the values?


Solution

  • The type mismatch message indicates that your variable is really string. That being so

    drop if missing(real(YR2013)) 
    destring YR2013, replace 
    

    is a way forward, as your variable will be no use otherwise.

    A more general recipe is

    destring *, ignore("..") replace