Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Egen .. Group Function

    Hello,

    I have a basic question about what egen and its group function is supposed to do. does it add or multiply the variables contained the group argument

    Code:
    webuse egenxmpl6, clear ///
    egen racesex = group(race sex)
    I followed the example above, and got racesex values that I am having difficulty interpreting. For example,

    ID #1 is a white(0) female(0). The racesex variable returns a value of 1.
    ID #2 is a white(0) male(1). But the racesex variable returns the value 2.

    I know this must be pretty obvious, but I am not sure how to interpret the grouped values ...

    I would appreciate some assistance in this regard.

    thanks - Yy


    Last edited by Yawo Kokuvi; 27 Apr 2019, 12:16. Reason: Better title

  • #2
    it just gives an ordinal number to each set of values for the full set of variables; the numbers run from 1 through "n" where "n" is just the number of different combinations of values of the variables used in the group() function; thus, it is essentially a counter for the number of distinct combinations of the values of the set of variables in your command

    added: if you use the "label" option, Stata will add value labels that may help

    Comment


    • #3
      Ohh, ok.. so white female will always have a value of 1, while white male will always return a value of 2.

      Ok.. this makes sense, since I am trying to recreate a new stratum variable for a pooled dataset (across different surveys) from the Demographic and Health surveys, and the group function helps in this regard.

      Ok.. thanks very much - yawo

      Comment


      • #4
        Rich gives excellent advice. See also https://journals.sagepub.com/doi/pdf...867X0800700407

        Comment

        Working...
        X