Announcement

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

  • How do you create a new variable with dummy variables

    I have a variable labeled nrrea which are the reasons why someone is working in field outside of their college major. i.e. pay, location ect. I used the following command to create a new variable labeled "mismatch" that includes all of these reasons.
    Code:
    egen mismatch=group( pay conditions locations interests family other)
    when I tabulate mismatch the frequency numbers for each group is off. Is there a better way to do this? Thank you.

  • #2
    I'm sorry to say that I am not able to fully understand your description of your data, neither from this post nor from your previous post which went unanswered. Even the best descriptions of data are no substitute for an actual example of the data. In order to get a helpful response, you need to show some example data.

    Be sure to use the dataex command to do this. If you are running version 15.1 or later, or a fully updated version 14.2, dataex is already part of your official Stata installation. If not, run ssc install dataex to get it. Either way, run help dataex and 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.

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


    Comment


    • #3
      Sorry I had to install it. This is the engineering variable I have. There are many different types of engineering majors and I want to combine it to a single engineering variable.
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float engineering
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      5
      7
      8
      1
      1
      1
      1
      1
      1
      9
      1
      1
      1
      9
      9
      1
      4
      9
      5
      1
      1
      9
      1
      1
      1
      9
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      4
      6
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      1
      end
      ------------------ copy up to and including the previous line ------------------

      Listed 100 out of 36707 observations
      Use the count() option to list more

      Comment


      • #4
        I used this code, but when I tab engineering it only has:
        . tab engineering

        engineering Freq. Percent Cum.

        0 29,042 77.26 77.26
        1 6,301 16.76 94.02
        2 2,248 5.98 100.00

        Total 37,591 100.00

        Code:
        gen engineering= (eng1+ eng2+ eng3+ eng4+ eng5+ eng6+ eng7+ eng8+ eng9)

        Comment


        • #5
          I do not see the relationship between post #3 (variable engineering) and post #1 (variables mismatch pay conditions locations interests family other).

          I do not see the relationship between the post #4 (tab command) and post #3 (example data). When I read the sample data from post #3 and run your tab command from post #4, the results are
          Code:
          . tab engineering
          
          engineering |      Freq.     Percent        Cum.
          ------------+-----------------------------------
                    1 |         87       87.00       87.00
                    4 |          2        2.00       89.00
                    5 |          2        2.00       91.00
                    6 |          1        1.00       92.00
                    7 |          1        1.00       93.00
                    8 |          1        1.00       94.00
                    9 |          6        6.00      100.00
          ------------+-----------------------------------
                Total |        100      100.00
          so it seems to me the engineering values in post #3 are not the same as the engineering values tabbed in post #4.

          Comment

          Working...
          X