Announcement

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

  • Distribution categorical variable between groups

    Hi there,

    I have a problem with my data.
    I have a categorical variable named education that indicates the level of education a person has. It has 6 categories, ranging from 1 (finished primary school) to 6 (finished university).
    I would like to compare the distribution of this categorical variable between groups, for example men and women (indicated by variable sex, 1=male, 2=female), and see if the distribution is somewhat similar.

    I don't know how to do this. I already made dummy variables for every level of education and I used graph bar to see the distribution. I found out that the distribution is not completely the same, but I don't mind a little bit of variation. As long as in general people in one group are not a lot more educated than people in the other group. In the attached file is the data.

    I gave here the example of men vs. women, but I would also like to see the difference between religious people vs. non-religious people (dummy variable religious), and the difference between sex and religious combined: sexrelig, with 1: men, non-religious 2: men, religious 3: women, non-religious 4: women, religious

    Could you help me? Thank you in advance.

    education.dta

  • #2
    Giving us an example of your data is a good idea, but we prefer you use dataex to give us these examples. Many of us don't like downloading files from unknown persons on the internet.

    What you are looking for is just a cross tabulation:

    Code:
    clear
    input double sex float(religious education)
    1 0 5
    1 0 4
    1 0 5
    1 0 4
    1 0 2
    1 0 3
    1 0 4
    1 0 3
    1 0 5
    1 0 5
    1 0 4
    1 0 5
    1 0 1
    1 0 5
    1 0 6
    1 0 5
    1 0 5
    1 0 6
    1 0 4
    1 0 5
    1 0 4
    1 0 5
    1 0 5
    1 0 5
    1 0 4
    1 0 4
    1 0 3
    1 0 6
    1 0 5
    1 0 5
    1 0 6
    1 0 5
    1 0 1
    1 0 4
    1 0 5
    1 0 4
    1 0 3
    1 0 5
    1 0 4
    1 0 4
    1 0 5
    1 0 4
    1 0 4
    1 0 5
    1 0 4
    1 0 6
    1 0 5
    1 0 5
    1 0 5
    1 0 5
    1 0 4
    1 0 5
    1 0 5
    1 0 6
    1 0 2
    1 0 5
    1 0 5
    1 0 5
    1 0 5
    1 0 4
    1 0 4
    1 0 4
    1 0 2
    1 0 4
    1 0 5
    1 0 6
    1 0 5
    1 0 5
    1 0 5
    1 0 4
    1 0 4
    1 0 4
    1 0 5
    1 0 5
    1 0 4
    1 0 5
    1 0 4
    1 0 5
    1 0 4
    1 0 5
    1 0 5
    1 0 2
    1 0 6
    1 0 5
    1 0 6
    1 0 5
    1 0 6
    1 0 4
    1 0 4
    1 0 3
    1 0 4
    1 0 6
    1 0 4
    1 0 4
    1 0 4
    1 0 5
    1 0 6
    1 0 5
    1 0 5
    1 0 1
    1 0 6
    1 0 6
    1 0 6
    1 0 6
    1 0 4
    1 0 4
    1 1 5
    1 1 3
    1 1 5
    1 1 4
    1 1 6
    1 1 5
    1 1 2
    1 1 5
    1 1 5
    1 1 6
    1 1 1
    1 1 6
    1 1 4
    1 1 5
    1 1 4
    1 1 5
    1 1 5
    1 1 4
    1 1 4
    1 1 6
    1 1 3
    1 1 5
    1 1 6
    1 1 6
    1 1 5
    1 1 6
    1 1 2
    1 1 5
    1 1 2
    1 1 5
    1 1 4
    1 1 4
    1 1 6
    2 0 6
    2 0 5
    2 0 5
    2 0 6
    2 0 6
    2 0 5
    2 0 5
    2 0 2
    2 0 6
    2 0 4
    2 0 4
    2 0 5
    2 0 2
    2 0 5
    2 0 6
    2 0 5
    2 0 4
    2 0 5
    2 0 4
    2 0 6
    2 0 5
    2 0 3
    2 0 4
    2 0 6
    2 0 5
    2 0 5
    2 0 6
    2 0 5
    2 0 6
    2 0 4
    2 0 4
    2 0 5
    2 0 4
    2 0 5
    2 0 4
    2 0 4
    2 0 6
    2 0 5
    2 0 4
    2 0 5
    2 0 6
    2 0 4
    2 0 5
    2 0 5
    2 0 4
    2 0 6
    2 0 4
    2 0 4
    2 0 5
    2 0 5
    2 0 5
    2 0 5
    2 0 5
    2 0 5
    2 0 6
    2 0 5
    2 0 6
    2 0 4
    2 0 5
    2 0 6
    2 0 4
    2 0 5
    2 0 4
    2 0 4
    2 0 6
    2 0 6
    2 0 5
    2 0 4
    2 0 6
    2 0 4
    2 0 5
    2 0 5
    2 0 6
    2 0 6
    2 0 4
    2 0 6
    2 0 5
    2 0 5
    2 0 4
    2 0 3
    2 0 5
    2 0 6
    2 0 6
    2 0 5
    2 0 5
    2 0 5
    2 0 5
    2 0 5
    2 0 3
    2 0 4
    2 0 4
    2 0 4
    2 0 5
    2 0 6
    2 0 5
    2 0 6
    2 0 2
    2 0 4
    2 0 6
    2 0 3
    2 0 5
    2 0 3
    2 0 2
    2 0 6
    2 0 2
    2 0 4
    2 0 6
    2 0 6
    2 0 5
    2 0 4
    2 0 4
    2 0 4
    2 0 5
    2 0 5
    2 0 5
    2 0 6
    2 0 4
    2 0 5
    2 0 4
    2 0 3
    2 0 5
    2 0 4
    2 1 6
    2 1 4
    2 1 5
    2 1 6
    2 1 3
    2 1 4
    2 1 5
    2 1 5
    2 1 4
    2 1 4
    2 1 3
    2 1 4
    2 1 3
    2 1 6
    2 1 4
    2 1 4
    2 1 6
    2 1 3
    2 1 5
    2 1 5
    2 1 5
    2 1 2
    2 1 6
    2 1 1
    2 1 5
    2 1 5
    2 1 5
    2 1 5
    2 1 6
    2 1 6
    2 1 6
    2 1 4
    2 1 4
    2 1 6
    2 1 4
    2 1 2
    2 1 5
    2 1 5
    2 1 4
    2 1 5
    2 1 4
    2 1 4
    2 1 6
    2 1 5
    2 1 5
    2 1 5
    2 1 4
    2 1 2
    2 1 5
    2 1 6
    2 1 5
    2 1 4
    2 1 5
    end
    label values sex gender
    label def gender 1 "Male", modify
    label def gender 2 "Female", modify
    label values education educationcat
    label def educationcat 1 "Primary school", modify
    label def educationcat 2 "Intermediate secondary education", modify
    label def educationcat 3 "Higher secondary education", modify
    label def educationcat 4 "Intermediate vocational education", modify
    label def educationcat 5 "Higher vocational education", modify
    label def educationcat 6 "University", modify
    
    tab educ sex, col nofreq
    tab educ religious, col nofreq
    bys religious: tab educ sex, col nofreq
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Maarten Buis

      Thank you so much!

      I didn't think about the data download, pretty stupid

      Is there any way to convert the data that i already had so that other people can generate these in a do-file without manually typing all the observations with corresponding values?

      Comment


      • #4
        Maarten Buis has already answered #4 at least by allusion

        we prefer you use dataex to give us these examples.
        For more details, please read FAQ Advice #12 at https://www.statalist.org/forums/help#stata

        Comment

        Working...
        X