Announcement

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

  • Need help/advice to create a table with data stratified over TWO categorical variables (nested stratification)

    Dear all,

    I need to use a Stata 11 command to come up with a table in which data of one variable (e.g., an average number of rice production in kg) are presented/stratified over TWO other categorical variables (e.g., education level and income level). This means something like a “nested stratification” although I am not sure if this is the right term for what I need. The table that I want to come up with may look roughly like the table below:
    Mean rice production (kg) s.d.
    Primary school
    High income
    Low income
    Medium income
    Secondary School
    High income
    Low income
    Medium income
    High School
    High income
    Low income
    Medium income
    I have searched online as well as in this forum but could not find the answers.

    If anyone know the answer or where to find the answer please help.

    Thank you

    Quynh

  • #2
    if you want it to look as above, use table with superrows (-h table-)

    Comment


    • #3
      Hi Rich,

      Thanks for your advice. I have tried a table with superrows. However, it did not allow me to get the mean of rice production, it only allowed frequency of rice production which is not what I want.

      The command and error message that I got when trying to get the mean was:

      ". table q71_n q541, contents(mean ) by(q5collapsed2)
      mean invalid or requires argument"

      Note:
      - variable q71_n - income level - is a categorical variable (byte type)
      - variable q541 - rice production - is a continuous variable (float type)
      - variable q5collapsed2 - education level - is a categorical variable (float type)

      Do you what kind of "argument" it requires in the command above to get the mean of q541 (rice production) on the table instead of frequency of rice production?

      Thank you

      Quynh

      Comment


      • #4
        If Stata were more informal, it might say "I see you want to show means; but the means of what? You have not said what." "What" is called the argument, a quaint word here even if you are used to it from mathematics. "Subject" is a roughly similar meaning.

        Examples are there in the help:

        Code:
        table rep78 foreign, c(mean mpg)
        But all this makes me wonder whether you want superrows at all. Your table sounds more like

        Code:
        table q71_n q5collapsed2, contents(mean q541)

        Comment


        • #5
          Hi Nick, very much appreciated your help. The code worked well and you are right I do not want super rows. Best regards, Quynh

          Comment

          Working...
          X