Announcement

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

  • Simple table with frequencies of variables with the same values/labels as multiple rows & a single column

    It just me or are 17's table & collect commands more confusing than ever?

    Anyway, all I'm trying to do is take a list of variables, all of which take on the same values (0, 1) and have the same labels (No, Yes) and put them all into the same table where each variable is a row and the column is the value label, and then the statistics are frequencies and percentages who were yes and no. Like:


    -----------------------------------
    |
    | No Yes Total
    --------------+--------------------
    |
    ageelig | 11 77 88
    othrelig | 5 157 162
    noelig | 19 120 139
    -----------------------------------


  • #2
    I don't know how to use table for such a table, but tabm (first written 1998) appears to do what you want. There is scope to show value labels, not assigned in this example. .

    Code:
    . webuse nlswork, clear
    (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
    
    . tabm msp nev_mar collgrad not_smsa c_city south union
    
                          |        values
                 variable |         0          1 |     Total
    ----------------------+----------------------+----------
    1 if married, spouse  |    11,324     17,194 |    28,518 
       1 if never married |    21,968      6,550 |    28,518 
    1 if college graduate |    23,739      4,795 |    28,534 
            1 if not SMSA |    20,469      8,057 |    28,526 
        1 if central city |    18,336     10,190 |    28,526 
               1 if south |    16,843     11,683 |    28,526 
               1 if union |    14,728      4,510 |    19,238 
    ----------------------+----------------------+----------
                    Total |   127,407     62,979 |   190,386 
    
    . tabm msp nev_mar collgrad not_smsa c_city south union , row
    
    +----------------+
    | Key            |
    |----------------|
    |   frequency    |
    | row percentage |
    +----------------+
    
                          |        values
                 variable |         0          1 |     Total
    ----------------------+----------------------+----------
    1 if married, spouse  |    11,324     17,194 |    28,518 
                          |     39.71      60.29 |    100.00 
    ----------------------+----------------------+----------
       1 if never married |    21,968      6,550 |    28,518 
                          |     77.03      22.97 |    100.00 
    ----------------------+----------------------+----------
    1 if college graduate |    23,739      4,795 |    28,534 
                          |     83.20      16.80 |    100.00 
    ----------------------+----------------------+----------
            1 if not SMSA |    20,469      8,057 |    28,526 
                          |     71.76      28.24 |    100.00 
    ----------------------+----------------------+----------
        1 if central city |    18,336     10,190 |    28,526 
                          |     64.28      35.72 |    100.00 
    ----------------------+----------------------+----------
               1 if south |    16,843     11,683 |    28,526 
                          |     59.04      40.96 |    100.00 
    ----------------------+----------------------+----------
               1 if union |    14,728      4,510 |    19,238 
                          |     76.56      23.44 |    100.00 
    ----------------------+----------------------+----------
                    Total |   127,407     62,979 |   190,386 
                          |     66.92      33.08 |    100.00 
    
    .

    tabm is part of the tab_chi package from SSC and requires only Stata 8.2.

    Comment


    • #3
      Exactly what I needed. Thank you, Nick, for both pointing to this...and for writing it! You're saving us all on here.

      Comment

      Working...
      X