Announcement

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

  • Splitting string variable 'Sector' into multiple variables.

    Hi, I have a string variable called 'sector' consisting of 9 different industry sectors. I want to split this variable into its 9 sub-sectors so I can then interact with each sub-sector with union to see whether union/non-union wages are higher.

    Does anybody know how I can split this string variable into 9 different variables for the different sectors?

  • #2
    Below is the STATA output
    Click image for larger version

Name:	Screenshot 2024-03-06 at 13.34.08.png
Views:	1
Size:	282.5 KB
ID:	1745721

    Comment


    • #3
      separate can do this, but in practice it is perhaps as or more likely that you would be better off using your sector variable to separate other variables with numeric values.

      Comment


      • #4
        Thank you for the response! For the second part, does that entail creating dummy variables for each sector (i.e., generating a variable such that Managers, Directors and Senior Office ==1)?

        Comment


        • #5
          separate is the tool of choice here for separating variables, which was your first question.

          For your regression problem, you don't need to separate or use indicator variables (dummy variables in your terminology) at all.

          Code:
          encode sector, gen(num_sector) 
          
          regress wages i.union i.num_sector
          with added interaction terms. See documentation on factor variables for that,

          Wages are often better analysed on logarithmic scale.

          Comment

          Working...
          X