program define gsum2 *! v1.5 gmh mar 5 2004 version 8.2 * gmean (mean) mpg, by(foreign) plot(line) msymbol(Oh) * |--clpse--| |--req'd--| |-plottype-| |--passed to graph---| preserve syntax anything(name = clist id = "-collapse- specification" equalok) [if] [in] [aweight fweight pweight iweight ], BY(varname max=1) [PLOT(string)] [twoway(string asis) order(varlist)] qui collapse `clist' [`weight'`exp'] `if' `in' , by(`by') capture order `order' capture confirm numeric variable `by' if _rc~= 0 { tempvar temp qui encode `by', gen(`temp') drop `by' rename `temp' `by' } if `"`plot'"' == "" { local plot = "connected" } qui gen ZZZZZZZZZZZZ=. move `by' ZZZZZZZZZZZZ capture drop ZZZZZZZZZZZZ unabbrev _all *di `"|`twoway'|"' /* local twoway = trim(`"`twoway'"') local l = length(`"`twoway'"') capture local twoway = substr(`"`twoway'"',8,`l'-8) di `"|`twoway'|"' */ gr twoway `plot' $S_1, `twoway' restore end