Descriptive statistics with if

Practical example 1

Dataset
StataData1.dta
Variable namegpa
Variable labelGrade point average (Age 15, Year 1985)
Value labelsN/A
Variable namesex
Variable labelSex
Value labels0=Man
1=Woman
sum gpa if sex==0

sum gpa if sex==1

Practical example 2

Dataset
StataData1.dta
Variable nameunemp_45
Variable labelDays in unemployment (Age 45, Year 2015)
Value labelsN/A
histogram unemp_45, freq

histogram unemp_45 if unemp_45!=0, freq

The first figure shows a histogram for unemp_45 – not very useful since there are so many individuals with the value 0. In the second histogram, the zeroes have been omitted so that it only shows individuals with at least one day in unemployment at age 45.