Announcement

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

  • Calculations gender

    Dear all

    The following table is a small representation of my dataset.
    Company name Number of current directors & managers DM Board, committee or department DM gender
    Volkswagen 115 Supervisory board M
    Member (presidential committee) M
    ... F
    ... ...
    Daimler AG 164 Board of directors M
    ... ... F
    ... ...
    I have 2 questions concerning this dataset.
    1) How can I calculate the number of females/males (DM gender) per company?
    (I want to do this for all companies, and I have around +/- 1400 companies in my dataset.)
    2) Can I filter the 'DM Board, Committee or department' by board of directors for example and how?

    I use Stata IC/16.

    Thanks a lot!

  • #2
    For help with code, you need to show example data from your Stata data set*, not a tableau that is suggestive of how the data look to human eyes. The actual code will depend on aspects of the actual data set that are not conveyed by that kind of tableau. Use the -dataex- command to post example data in this forum. As you are running version 16, -dataex- is already part of your official Stata installation. So, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    Concerning question 2, what do you mean by "filter" here? Do you mean getting one set of results just for the Board of directors and another set of results for everything else?

    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    *If you have not yet imported your data into Stata, it is premature to ask these questions.

    Comment


    • #3
      Click image for larger version

Name:	Schermafbeelding 2021-04-06 om 22.54.29.png
Views:	1
Size:	1.59 MB
ID:	1601947

      I am sorry, this is my dataex.

      For the second question, I only want the results where 'DM board, committee or department' is 'board of directors' for example.

      Comment


      • #4
        No, that's not your -dataex-. That's a screenshot of your -dataex-, and there are few things more useless than a screenshot of -dataex-: it actually defeats the purpose of using -dataex-. The correct way to use -dataex- is to copy/paste the output that -dataex- sends to your Results window into the editor here.

        Nevertheless, I can deduce enough from what I see there to answer your specific questions. The first problem you have is that companyname is missing almost all the time. I guess this data is imported from a spreadsheet that is intended for human visual appreciation, and the company name is shown only in the first row it applies to. Great for human eyes; deadly for computing. So the first thing to do is fill that in.

        Code:
        replace company_name = company_name[_n-1] if missing(company_name)
        
        by company_name, sort: egen n_males = total(dmgender == "M")
        by company_name: egen n_females = total(dmgender == "F")
        
        by company_name: egen n_male_directors = total(dmgender == "M" & dmboardcommitteeordepartment == "Board of Directors")
        by company_name: egen n_female_directors = total(dmgender == "F" & dmboardcommitteeordepartment == "Board of Directors")
        Note: Because usable example data was not provided, this code is untested. It may contain typos.

        Comment

        Working...
        X