program def histplot
*! NJC 1.0.2 26 January 1999
* NJC 1.0.1 4 Sept 1998
* NJC 1.0.0 31 August 1998
        version 5.0
        local varlist "req ex max(1)"
        local if "opt"
        local in "opt"
        local weight "aweight fweight iweight"
        local options "Width(real 0) Ulinc BY(str) JOIN FRac TOtal *"
        parse "`*'"
        if "`by'" != "" { local byby "by(`by')" }
        if "`total'" == "total" {
                di _n in bl "Sorry: total option not available"
        }

        tempvar bgen fgen
        genfreq `varlist' `if' `in' [`weight' `exp'], /*
         */ w(`width') bg(`bgen') fg(`fgen') `ulinc' `byby'
        if "`frac'" == "frac" { qui replace `fgen' = `fgen' / $S_1 }
        barplot `fgen' `bgen', w(`width') `join' `byby' `options'
end