Announcement

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

  • using table for a three way cross-tabulation

    I am trying out the new table command, to create a three way cross tabulation (is there a difference between East and West Germany in the opinions on the role of women after one controls for religious affiliation). I got far, but there are still two problems where I am stuck.

    Within each panel I am showing column percentages. I would like to emphasize this by adding column totals to each panel (they would be all 100%)

    The variable labels for relig (religious affiliation) and husb_career (wife should support husband's career) are not necessary as the value labels contain all the relevant information and I would like to remove them from the table

    Code:
    . clear
    
    . input byte(eastwest husb_career relig) int freq
    
         eastwest  husb_career     relig      freq
      1. 1 0 0  2177
      2. 1 0 1 10582
      3. 2 0 0  2396
      4. 2 0 1   892
      5. 1 1 0   509
      6. 1 1 1  5236
      7. 2 1 0   590
      8. 2 1 1   387
      9. end
    
    . label values eastwest eastwest
    
    . label def eastwest 1 "West", modify
    
    . label def eastwest 2 "East", modify
    
    . label values husb_career husb_career
    
    . label def husb_career 0 "wife can prioritize own career", modify
    
    . label def husb_career 1 "wife should support husband's career", modify
    
    . label values relig relig
    
    . label def relig 0 "non-religious", modify
    
    . label def relig 1 "religious", modify
    
    . label var eastwest "Region of Germany"
    
    . label var husb_career "wife should support husband's career"
    
    . label var relig "religious affiliation"
    
    .
    . qui table (relig var)  (eastwest)  [fw=freq], ///
    >  stat(fvpercent husb_career) nformat(%9.0f) sformat("%s%%")
    
    .  
    . collect style row stack, nobinder spacer
    
    .
    . collect preview
    
    -------------------------------------------------------------------
                                               |    Region of Germany  
                                               |   West    East   Total
    -------------------------------------------+-----------------------
    religious affiliation                      |                       
      non-religious                            |                       
        wife should support husband's career   |                       
          wife can prioritize own career       |    81%     80%     81%
          wife should support husband's career |    19%     20%     19%
                                               |                       
      religious                                |                       
        wife should support husband's career   |                       
          wife can prioritize own career       |    67%     70%     67%
          wife should support husband's career |    33%     30%     33%
                                               |                       
      Total                                    |                       
        wife should support husband's career   |                       
          wife can prioritize own career       |    69%     77%     70%
          wife should support husband's career |    31%     23%     30%
    -------------------------------------------------------------------
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

  • #2
    Hi Maarten Buis. The -percent- statistic has a -total- option that may be helpful. And -collect style header- may be used to hide the variable labels. Not sure the -binder- was needed, but it doesn't hurt. So using your data I tried the following

    Code:
    table (relig husb_career)  (eastwest)  [fw=freq], ///
      stat(percent, across(husb_career)) nformat(%9.0f) sformat("%s%%")
    collect style header relig, title(hide)
    collect style header husb_career, title(hide)
    collect style row stack, spacer
    collect preview
    which produces

    Code:
    ---------------------------------------------------------------
                                           |    Region of Germany  
                                           |   West    East   Total
    ---------------------------------------+-----------------------
    non-religious                          |                       
      wife can prioritize own career       |    81%     80%     81%
      wife should support husband's career |    19%     20%     19%
      Total                                |   100%    100%    100%
                                           |                       
    religious                              |                       
      wife can prioritize own career       |    67%     70%     67%
      wife should support husband's career |    33%     30%     33%
      Total                                |   100%    100%    100%
                                           |                       
    Total                                  |                       
      wife can prioritize own career       |    69%     77%     70%
      wife should support husband's career |    31%     23%     30%
      Total                                |   100%    100%    100%
    ---------------------------------------------------------------
    Is this what you meant?

    Comment


    • #3
      German Rodriguez 'Yes, that looks good. Thank you.
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment

      Working...
      X