Announcement

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

  • Tabulation/Descriptive Statistics

    Greetings Everyone!

    Hopefully, you will be doing well. I have variable gender diversity in number. I have sub-divided this variable in the following way,
    HTML Code:
    gen DV1 = diversityinnumber == 1 if !mi(diversityinnumber)
    gen DV2 = diversityinnumber == 2 if !mi(diversityinnumber)
    gen DV3 = diversityinnumber == 3 if !mi(diversityinnumber)
    gen DV4 = diversityinnumber > 3 if !mi(diversityinnumber)
    After that now i wanted to do tabulation or summary statistics that howmany companies have 1 female in the board or two females in the board or three female in the board etc. Kindly help me in this regard. Warms Regards Sattar Khan

  • #2
    Hello!

    I'd suggest making all the four DV# as just one variable that takes values of 1, 2, 3, and 4 based on the coding scheme. And then using -bysort- or -statsby- to make multiple summaries. See below for what I mean. (Also, is there no company with 0 female in the board?)

    Code:
    clear
    
    input diversityinnumber
    1
    2
    3
    4
    5
    6
    .
    end
    
    recode diversityinnumber (1 = 1 "1 female") ///
                             (2 = 2 "2 females") ///
                             (3 = 3 "3 females") ///
                             (nonmissing = 4 "4 or more females") ///
                             (missing = .), into(dv)
    
    * Subgroup summary
    gen somevariable = rnormal()
    bysort dv: sum somevariable

    Comment


    • #3
      Originally posted by Ken Chui View Post
      Hello!

      I'd suggest making all the four DV# as just one variable that takes values of 1, 2, 3, and 4 based on the coding scheme. And then using -bysort- or -statsby- to make multiple summaries. See below for what I mean. (Also, is there no company with 0 female in the board?)

      Code:
      clear
      
      input diversityinnumber
      1
      2
      3
      4
      5
      6
      .
      end
      
      recode diversityinnumber (1 = 1 "1 female") ///
      (2 = 2 "2 females") ///
      (3 = 3 "3 females") ///
      (nonmissing = 4 "4 or more females") ///
      (missing = .), into(dv)
      
      * Subgroup summary
      gen somevariable = rnormal()
      bysort dv: sum somevariable
      HTML Code:
      recode diversityinnumber (1 = 1 "1 female") ///
      Rules defining value labels not allowed when overwriting a variable
      r(198);
      Dear Chui
      following error appear when applying the code

      Comment


      • #4
        It's likely caused by the generated variable already created. If you use a -drop xxxxx- command to drop that variable first, then the recode should work.

        Comment

        Working...
        X