*! gcreset 0.5.1 2009-05-23 scott long

//  reset globals

capture program drop gcreset
program define gcreset, rclass

    version 9
    syntax , ///
        [   all  /// reset all
            gcsetup /// reset needed by gcsetup
            gcmodel /// reset globals used in gcmodel
        ]

    if "`all'"=="all" {
        local gcsetup "gcsetup"
        local gcmodel "gcmodel"
    }

//  RESET GCSETUP

    if "`gcsetup'"=="gcsetup" {

        global grpvar " " // name of varible defining groups
        global gr0var    " " // group 0 stem; name of variable equal to 1 if grp 0
        global gr1var    " " //
        global gr0label  " " // label for group 0
        global gr1label  " " //

        global grp       " " // <grpvar>==1
        global gr0       " " // <gr0var>==1
        global gr1       " " // <gr1var>==1

        global xallmng   " " // x=mnx  z=mnz
        global xallmn0   " " // x=mnx0 z=mnz0
        global xallmn1   " " // x=mnx1 z=mnz1

        global xgr0mng   " " // f0x=mnx f0z=mnz
        global xgr0mn0   " " // f0x=mnx0 f0z=mnz0
        global xgr0mn1   " " // f0x=mnx1 f0z=mnz1

        global xgr1mng   " " //
        global xgr1mn1   " " //
        global xgr1mn0   " " //

        global rhsgr0    " " // f0 f0x f0z
        global rhsgr1    " " // f1 f1x f1z
        global rhsinteract " " // rhsgr0 + rhsgr1
        global rhsnoint  " " // grpvar + x z
    }

//  RESET GCMODEL

    if "`gcmodel'"=="gcmodel" {

        macro drop modellabel   // label for this call of gcpecify
        macro drop g            // group variable set to 1
        macro drop gr0          // group 0 variable set to 1
        macro drop gr1          // group 1 variable set to 1
        macro drop rhsgr0       // rhs vars for group 0
        macro drop rhsgr1       // rhs vars for group 1
        macro drop rhsnoint     // rhs variables for in no intereraction model
        macro drop rhsinteract    // rhs variables for in intereraction model
        macro drop xallmng      // non-interaction vars set to grand means
        macro drop xallmn0      // non-interaction vars set to group 0 means
        macro drop xallmn1      // non-interaction vars set to group 1 means
        macro drop xgr0mng      // group 0 interaction vars set to global means
        macro drop xgr0mn0      // group 0 interaction vars set to group 0 means
        macro drop xgr0mn1      // group 0 interaction vars set to group 1 means
        macro drop xgr1mng      // group 1 interaction vars set to global means
        macro drop xgr1mn1      // group 1 interaction vars set to group 1 means
        macro drop xgr1mn0      // group 1 interaction vars set to group 0 means
    }

end
exit

* gcreset 0.5.0 2009-05-22 jsl reset globals