Announcement

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

  • How to merge variables?

    Hello!

    I have three variables containing different things in the same dataset.

    - Gender variable (v117): 0= male 1= female
    - Employment variable (v246): 1= working 2=unemployed 3= pensioners etc etc.
    - Job sector variable (v347): 0=private sector 1= public sector

    These i need to be combined to a group which contains female from gender variable, the working from employment variable and the private from the job sector variable. This variable is those who are dependent on the welfare state versus the rest.

    But how do i create a new variable where 0=depended on the welfare state and 1= in depended on the welfare state from these variables?

  • #2
    I'm not sure what you mean by the welfare state or what you mean to be dependent upon it, but you can create variables using an if expression to qualify which observations get which value in the new variable being created, for example
    Code:
    generate byte mynewvar = v117 == 1 & inlist(v246, 2, 3) & v347 == 1

    Comment


    • #3
      I suggest starting with the list's FAQ, paying particular attention to Sections 9 and 12 (but don't overlook Section 6), and then take a look at the help files for Stata's logical operators, then generate and then if.

      Comment


      • #4
        Lange seems to want a new variable (let's call it - Deprivated people - ) that represents a union of different features specified in v117, v246 and v347.
        I would figure out the following solution (that, however, I did not test):
        -------------------------------------------------------------------------------
        g Deprivated_people=1 if v117==1 | v246!=1 | v347==1
        replace ~~Deprivated_people=0 if ~~Deprivated_people==.
        ------------------------------------------------------------------------------

        Kind regards,
        Carlo
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment


        • #5
          I believe the best help you can get (by yourself) is
          1. to follow the advice of Joseph (post #4)
          2. to study the example given by Joseph (post #2) and Carlo (post #5) (thereby applying what you learned in step 1)
          3. to generate the variable "independent" (or whatever you call it) they way you described in your last post (#6)
          4. to test whether you really obtained the results you were looking for by using Stata's tab2 command with the option firstonly, for example:
          Code:
          tab2 independent gender employment jobsector, firstonly
          You should also consider carefully whether the implicit definition of "independence" you proposed in your last post really makes sense. For example, should a woman employed fulltime as a public worker be classified as dependent (or depended)? But this is no longer a technical Stata question but a substantive decision of your own.
          Last edited by Dirk Enzmann; 27 Apr 2014, 06:34.

          Comment


          • #6
            how about something like this:

            Code:
            webuse lbw, clear
            egen mygroup = group(low race smoke), l
            tab1 mygroup
            You can recode the variable however you want then.
            -------------------------------------------
            Richard Williams, Notre Dame Dept of Sociology
            StataNow Version: 18.5 MP (2 processor)

            EMAIL: [email protected]
            WWW: https://www3.nd.edu/~rwilliam

            Comment


            • #7
              Cross-posted at http://www.talkstats.com/showthread....erge-variables

              Please note our protocol on cross-posting in different forums in the Advice Guide (which also advises use of full real names).

              Comment

              Working...
              X