program denscomp
version 9
syntax varname(numeric) [if] [in], by(varname) at(varname numeric)
marksample touse
kdensity `varlist' if `by'==1 & `touse', gen(fmen) at(`at') nodraw
kdensity `varlist' if `by'==2 & `touse', gen(fwomen) at(`at') nodraw
graph twoway connected fmen fwomen xhelp ///
, title(Income by Gender) ytitle(Density) xtitle(Log (Income)) ///
legend(label(1 "Men") label(2 "Women"))
end
