Announcement

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

  • Matching variables from two columns

    Hi, everyone!

    I have two columns with dummy variables, each '0' and '1'. And I want to merge these to columns and make a single column. But I want my values in a new column to be matched like:

    1) If I05_11 is '1', then match with I05_12 '1'
    2) If I05_11 is '1', then match with I05_12 '0'
    3) If I05_11 is '0', then match with I05_12 '0'
    4) If I05_11 is '0', then match with I05_12 '1'

    I05_11 I05_12
    0 1
    1 1
    1 0
    0 0
    1 0

    How can I get this result?

    Thank you very much beforehand!
    Regards,
    Orif
    Using Stata 16/MP

  • #2
    It might just be me, but I cannot make sense of what you want. Can you show how you want the new column to look like?

    Comment


    • #3
      Thank you, Andrew!

      I have observations where people were asked to answer some questions about qualification and skill match with their current jobs.

      (1) First question (I05_11) was "Is your current job match with your specialty/education?" - answers are 'yes' and 'no'
      (2) Second question (I05_12) was "Have you ever received special vocational training for your current job?" - answers are 'yes' and 'no'

      So, if person answers (1) his job doesn't match his education and (2) he didn't receive any vocational training (that is 'No' for both questions) then he has an overqualification problem. If he answers (1) his job matches his education and (2) he recieved vocational training/or didn't recieve then he does not have an overqualification problem.

      My goal is to combine two answers in a way that it creates new variables, one indicating existence of overqualification '1' and second indicating no problem of overqualification '0'.

      I05_11 I05_12 Matched
      Yes No No (not overqualified)
      No No Yes (overqualified)
      Yes No No (not overqualified)
      Yes Yes No (not overqualified)

      I hope now I explained in a correct way. Waiting forward for the solution.
      Regards,
      Orif
      Using Stata 16/MP

      Comment


      • #4
        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input byte(i05_11 i05_12)
        0 1
        1 1
        1 0
        0 0
        1 0
        end
        
        egen wanted= group(i05_11 i05_12)
        lab define wanted 1 "Yes (overqualified)" 2 "No (not overqualified)" 3 "No (not overqualified)" 4 "No (not overqualified)"
        lab values wanted wanted

        Res.

        Code:
        . l
        
             +------------------------------------------+
             | i05_11   i05_12                   wanted |
             |------------------------------------------|
          1. |      0        1   No (not overqualified) |
          2. |      1        1   No (not overqualified) |
          3. |      1        0   No (not overqualified) |
          4. |      0        0      Yes (overqualified) |
          5. |      1        0   No (not overqualified) |
             +------------------------------------------+

        Added in edit: For a dummy overqualified/ not overqualified

        Code:
        gen overqualified= wanted==1
        gen not_overqualified= wanted!=1
        Last edited by Andrew Musau; 05 Nov 2019, 06:30.

        Comment


        • #5
          Originally posted by Andrew Musau View Post
          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input byte(i05_11 i05_12)
          0 1
          1 1
          1 0
          0 0
          1 0
          end
          
          egen wanted= group(i05_11 i05_12)
          lab define wanted 1 "Yes (overqualified)" 2 "No (not overqualified)" 3 "No (not overqualified)" 4 "No (not overqualified)"
          lab values wanted wanted

          Res.

          Code:
          . l
          
          +------------------------------------------+
          | i05_11 i05_12 wanted |
          |------------------------------------------|
          1. | 0 1 No (not overqualified) |
          2. | 1 1 No (not overqualified) |
          3. | 1 0 No (not overqualified) |
          4. | 0 0 Yes (overqualified) |
          5. | 1 0 No (not overqualified) |
          +------------------------------------------+

          Added in edit: For a dummy overqualified/ not overqualified

          Code:
          gen overqualified= wanted==1
          gen not_overqualified= wanted!=1
          Thank you, Andrew!

          It helped a lot.
          Regards,
          Orif
          Using Stata 16/MP

          Comment

          Working...
          X