Announcement

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

  • How to create a variable from a single variable by using bysort condition?

    Hi,

    I have an education variable taking values from 1 to 15. A gender variable takes values from 1 to 2. The wage variable contains wages for all the observations. My aim is to conduct a t-test and export the results in latex to know the difference in male and female earnings based on the education categories. The paper that I am trying to replicate uses the following code to modify wages: (Wmen - Wwomen)*100/Wmen

    Here Wmen and Wwomen are the geometric means of the wage variable.

    I have tried the following:

    Code:
    bysort XED6 XRO3: egen gm = gmean(XWSHOURLY)
    
    by XED6: ttest gm, by(XRO3)
    However, this does not allow me to use the formula that I want to generate. I have attached a sample of the data set.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int(XED6 XRO3) float gm
    12 2  27.47607
    15 1   49.9775
    15 1   49.9775
    15 1   49.9775
     9 1 17.724064
     0 1 12.805625
     0 1 12.805625
     0 1 12.805625
     0 1 12.805625
     0 1 12.805625
     0 1 12.805625
    12 1  27.37443
    10 1  24.38213
     0 1 12.805625
    15 1   49.9775
    12 2  27.47607
     8 1 17.921606
     9 1 17.724064
     0 1 12.805625
    10 1  24.38213
    12 1  27.37443
    15 1   49.9775
    10 1  24.38213
    15 1   49.9775
     8 1 17.921606
     0 1 12.805625
     0 1 12.805625
     4 1 13.954074
     0 1 12.805625
     9 2  10.48608
    15 1   49.9775
     5 1  15.19212
     0 1 12.805625
    11 1 20.515743
     0 1 12.805625
     0 1 12.805625
     8 1 17.921606
     0 1 12.805625
     8 1 17.921606
     6 1  15.13683
     0 1 12.805625
     5 1  15.19212
     5 1  15.19212
     9 1 17.724064
     7 1  15.77426
     9 1 17.724064
     1 1 12.315355
     9 1 17.724064
     0 2  8.197947
     9 1 17.724064
    15 1   49.9775
    10 1  24.38213
     5 1  15.19212
    11 1 20.515743
     9 1 17.724064
     9 1 17.724064
    10 1  24.38213
    13 1  31.57161
    10 1  24.38213
     0 1 12.805625
     8 1 17.921606
     0 1 12.805625
    15 1   49.9775
     0 1 12.805625
     0 1 12.805625
    11 1 20.515743
    15 1   49.9775
     9 1 17.724064
    11 1 20.515743
    15 1   49.9775
    10 1  24.38213
    15 1   49.9775
    15 1   49.9775
    10 1  24.38213
     5 1  15.19212
     5 1  15.19212
     0 1 12.805625
    10 1  24.38213
     3 1   13.1444
     9 1 17.724064
     0 1 12.805625
    11 1 20.515743
     6 1  15.13683
     0 1 12.805625
     0 1 12.805625
     0 1 12.805625
     0 1 12.805625
     0 1 12.805625
     9 1 17.724064
     9 1 17.724064
     9 1 17.724064
     9 1 17.724064
     9 1 17.724064
    15 1   49.9775
    11 1 20.515743
     9 1 17.724064
     9 1 17.724064
     9 1 17.724064
     0 1 12.805625
     0 1 12.805625
    end
    label values XED6 XED6
    label def XED6 0 "none, <1 0", modify
    label def XED6 1 "1st class 1", modify
    label def XED6 3 "3rd class 3", modify
    label def XED6 4 "4th class 4", modify
    label def XED6 5 "5th class 5", modify
    label def XED6 6 "6th class 6", modify
    label def XED6 7 "7th class 7", modify
    label def XED6 8 "8th class 8", modify
    label def XED6 9 "9th class 9", modify
    label def XED6 10 "Secondary 10", modify
    label def XED6 11 "11th Class 11", modify
    label def XED6 12 "High Secondary 12", modify
    label def XED6 15 "Bachelors 15", modify
    label values XRO3 XRO3
    label def XRO3 1 "Male 1", modify
    label def XRO3 2 "Female 2", modify
Working...
X