program define muxplot *! 1.2.0 NJC 16 June 1999 version 6.0 syntax varlist(min=3) [if] [in] [fweight aweight iweight] /* */ [ , BY(str) Need(str) Connect(str) Symbol(str) Link * ] if "`link'" != "" & "`connect'" != "" { di in r "connect() may not be combined with link()" exit 198 } tokenize `varlist' local nvars : word count `varlist' local y "`1'" mac shift local nvarsm1 = `nvars' - 1 preserve tempvar id Y X Xmin gen `id' = _n if "`exp'" != "" { tempvar w gen `w' `exp' /* `exp' might not be a variable */ local exp "= `w'" } local i = 1 while `i' < `nvars' { local stargs "`stargs' `y' ``i'' `id' `w' `need'" local Xlab`i' : variable label ``i'' if "`Xlab`i''" == "" { local Xlab`i' "``i''" } local Xlist "`Xlist' ``i''" tempvar Y`i' local Ylist "`Ylist' `Y`i''" local i = `i' + 1 } stack `stargs' `if' `in', into(`Y' `X' `id' `w' `need') clear local i = 1 while `i' < `nvars' { qui gen `Y`i'' = `Y' if _stack == `i' label var `Y`i'' "`Xlab`i''" local i = `i' + 1 } label var `X' "`Xlist'" if "`by'" != "" { sort `by' local byby "by(`by')" } if "`connect'" == "" { local connect : di _dup(`nvarsm1') "." } if "`symbol'" == "" { local symbol = substr("opdOTS.",1,`nvarsm1') + "i" } else { local symbol "`symbol'i" } qui if "`link'" == "link" { egen `Xmin' = min(`X'), by(`id') replace `Xmin' = - `Xmin' sort `by' `Xmin' `id' `X' local connect "`connect'L" } gra `Ylist' `Y' `X' [`weight' `exp' ] , `byby' /* */ s(`symbol') c(`connect') `options' end