Announcement

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

  • How to summarize three variables using a table?

    Hi, I have a age and wage variable that is continuous and level of education. What would the best way to summarize mean wage for different age categories and level of education in a table. Any suggestion on how to visualize it would be greatly appreciated. Thanks.

  • #2
    If I understand you correctly your age variable is categorical and education variable too is categorical with only wage as continuous. If this holds then you can use a stata command to get a three way contingency table.
    the command for this is:
    bys age: su wage if level ==1 where 1 is the codename for 1st category. so if your level of education variable have 3 categories say 1=primary, 2=secondary, 3=tertiary, then you will repeat the same command 3 times with the respective codenames. eg
    bys age: su wage if level ==1
    bys age: su wage if level ==2
    bys age: su wage if level ==3

    this means you are summarizing mean wage across age categories and level of education categories.
    All the best

    Comment


    • #3
      If you wish a direct command, you may try something like this:

      Code:
      . sysuse nlsw88.dta
      (NLSW, 1988 extract)
      
      . tab race married, sum(age)
      
           Means, Standard Deviations and Frequencies of age in current year
      
                 |       married
            race |    single    married |     Total
      -----------+----------------------+----------
           white | 39.414784  39.212174 |  39.27245
                 | 3.0926082  3.0707114 | 3.0776908
                 |       487       1150 |      1637
      -----------+----------------------+----------
           black | 38.928803  38.678832 | 38.811321
                 | 2.9697794  2.9918921 | 2.9802458
                 |       309        274 |       583
      -----------+----------------------+----------
           other |      38.5  39.666667 | 39.307692
                 | 2.8284271  3.4299717 | 3.2467735
                 |         8         18 |        26
      -----------+----------------------+----------
           Total | 39.218905  39.116505 | 39.153161
                 | 3.0499112  3.0660582 | 3.0600022
                 |       804       1442 |      2246
      If I understood correctly, you only wanted the mean, but the command above provides SDs and counts as well,

      Shall you really need only the means, you may use - means - option for that:

      Code:
      . tab race married, sum(age) means
      
                             Means of age in current year
      
                 |       married
            race |    single    married |     Total
      -----------+----------------------+----------
           white | 39.414784  39.212174 |  39.27245
           black | 38.928803  38.678832 | 38.811321
           other |      38.5  39.666667 | 39.307692
      -----------+----------------------+----------
           Total | 39.218905  39.116505 | 39.153161
      Hopefully that helps.
      Last edited by Marcos Almeida; 20 Oct 2017, 04:18.
      Best regards,

      Marcos

      Comment


      • #4
        Thank you everyone for your suggestions. They were extremely helpful.

        Comment

        Working...
        X