*! gdset2 0.2.2 2008-01-27
*   > add xisg0mn1 and xisg1mn0
* gdset2 0.2.1 2008-01-25   > dummy out globals

* create globals used for gd commands

capture program drop gdset2
program define gdset2, rclass
    version 9

//  Note: can be run before logit - check estimation command

//  DECODE OPTIONS & SETUP PRINTING PARAMETERS

    syntax ,                ///
        [                   ///
        gvar(varname)       /// group variable
        g0var(string)       /// name of variable equal to 1 for group 0
        g1var(string)       /// name of variable equal to 1 for group 1
        g0label(string)     /// label for group 1
        g1label(string)     /// label for group 1
        Details             /// list details
        Reset               /// reset globals
        ]

//  RESET GLOBALS

    if "`reset'"=="reset" {

        capture macro drop g0var    // Name of new variable equal to 1 if group 0.
        capture macro drop g1var    // Name of new variable equal to 1 if group 1.
        capture macro drop gis      // gvar=1 (e.g., male=1)
        capture macro drop gisg0    // g0label=1 (e.g., f0=1)
        capture macro drop gisg1    // g1label=1 (e.g., m1=1)
        capture macro drop g0label  // Short label for group 0.
        capture macro drop g1label  // Short label for group 1.
        capture macro drop gvar     // Name of variable defining groups.
        capture macro drop xis      // RHS variables set to grand means.
        capture macro drop xisg0    // RHS by group 0 interaction variables set to grand means.
        capture macro drop xisg0mn0 // RHS by group 0 interaction variables set to group 0 means.
        capture macro drop xisg1    // RHS by group 1 interaction variables set to grand means.
        capture macro drop xisg1mn1 // RHS by group 1 interaction variables set to group 1 means.
        capture macro drop xismn0   // RHS variables set to group 0 means.
        capture macro drop xismn1   // RHS variables set to group 1 means.
        * 2008-01-27
        capture macro drop xisg0mn1 // RHS by group 0 interaction variables set to group 1 means.
        * 2008-01-27
        capture macro drop xisg1mn0 // RHS by group 1 interaction variables set to group 0 means.

        * what is this for? 2008-01-25
        if "`gvar'"=="" {
            exit
        }
    }

//  CREATE GLOBALS

    * variable defining group
    if "`gvar'"!="" {
        global gvar "`gvar'"
    }
    * names for groups and labels
    foreach g in 0 1 {
        if "`g`g'var'"!="" {
            global g`g'var "`g`g'var'"
        }
        if "`g`g'label'"!="" {
            global g`g'label "`g`g'label'"
        }
    } // foreach g

//  DETAILS

    if "`details'"=="details" {

        di _new "These globals were created:"
        di _new "    \$gvar:     $gvar"
        di      "    \$g0var:    $g0var"
        di      "    \$g0label:  $g0label"
        di      "    \$g1var:    $g1var"
        di      "    \$g1label:  $g1label"

    }

* 2008-01-25 dummy out the globals used later

gdxis2, reset

end
exit

//  History

* gdset1 0.1.0 2007-03-11
* gdset1 0.1.1 2007-03-12 > Add reset for all globals.
* gdset1 0.1.2 2007-03-13 > Reset does not exit.
* gdset1 0.1.3 2007-03-13 > Cleanup and rename.
* gdset1 0.1.4 2007-03-15 > Reset exits if nothing else specified.
* gdset2 0.2.0 2007-03-22 >