By default Stata commands operate on all observations of the current dataset; the if and in keywords on a command can be used to limit the analysis on a selection of observations (filter observations for analysis).
if=logical_expression (a logical expression of any complexity)
list country continent urb if infmor>25 | Lists only observations where infant mortality is greater than 25 | |
histogram urb if continent != 6 | Histogram for all countries except those from continent 6 | |
list urb if country=="CH " | List value of country "CH " |
list urb in 1/10 | List the first ten observations |
list country continent urb in -10/l | List the last ten observations (you can use l for last and f for first. |
If you need to perform many analyses only on a subset it it might be useful to remove observations that are of no interest from the dataset for that particular sequence of analyses
drop if urb>50 | Drop all observation with urbanization >50 from the dataset |