Skip to content

Instantly share code, notes, and snippets.

@acarril
Created December 13, 2017 13:55
Show Gist options
  • Save acarril/00c89acb9a2e0d137178ac3918cb8ff9 to your computer and use it in GitHub Desktop.
Save acarril/00c89acb9a2e0d137178ac3918cb8ff9 to your computer and use it in GitHub Desktop.
Plot stacked missing and non-missing values over time (or some other discrete variable)
// Plot stacked missing and non-missing values over time (or some other discrete variable)
// Syntax: plotmissing var timevar
program define plotmissing
tempvar has hasnt
gen `has' = (!mi(`1'))
gen `hasnt' = (mi(`1'))
graph hbar (sum) `has' `hasnt', ///
over(`2', label(labsize(vsmall))) ///
stack legend(order(1 "Non-missing" 2 "Missing")) ///
subtitle(Relative frequency of non-missing '`1'')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment