* !galbr.ado AT v2.0, Marc 2000     (STB-56: sbe20.1)
* galbr.ado AT v1.15, June/October 1997

program def galbr
    version 6.0
    syntax varlist(min=2 max=2 numeric) [if] [in] [, id(varname) `options' *]
    tokenize `varlist'
    local E  `1'
    local SE `2'
    preserve
    if ("`if'"!="") {
       qui keep `if'
    } 
    if ("`in'"!="") {
       qui keep `in'
    } 
    if "`id'"=="" {
       local id "O"
    } 
    else {
        local id "[`id']"
    }
    tempvar x y p ulp llp
    qui gen `x'=1/`SE'
    qui gen `y'=`E'/`SE' 
    label var `x' "1/se(b)"
    label var `y' "b/se(b)"
    qui reg `y' `x', noconstant
    qui predict `p' 
    qui gen `llp'=`p'-2 
    qui gen `ulp'=`p'+2 
    qui sum `x', detail
    local mxx=r(max)
    qui sum `llp', detail
    if r(min)>=-2 {
       local mny=-2
    } 
    else {
       local mny=r(min)
    }
    qui sum `ulp', detail
    if _result(6)<=2 {
       local mxy=2
    } 
    else {
       local mxy=r(max)
    }
    local new=_N+1
    qui set obs `new'
    qui replace `y'=0 in l
    qui replace `x'=0 in l
    qui replace `p'=0 in l
    qui replace `llp'=-2 in l
    qui replace `ulp'=2 in l 
    graph `y' `p' `ulp' `llp' `x', ylab(`mny',-2,0,2,`mxy') /* 
       */ xscale(0,`mxx') ysca(`mny',`mxy') pen(1922) /*
       */ sy(`id'iii) c(.lll) sort `options' 
end
