Announcement

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

  • Question (Mean median category)

    Dear all,

    I have the following dataset

    Code:
     * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(country year) str2 isic float(ValueAdded Employment val_per_worker tech_intensity)
    8 1995 "15"         .  4515         . 1
    8 1996 "15"         .  5836         . 1
    8 1997 "15"         .  8599         . 1
    8 1998 "15"         .  4316         . 1
    8 1999 "15"         .  4032         . 1
    8 2000 "15"  13920062  3919 3551.9424 1
    8 2001 "15"  14884939  3144 4734.3955 1
    8 2002 "15"  17994426  3790 4747.8696 1
    8 2003 "15"  27076334  3965  6828.836 1
    8 2004 "15"  36551080  4599  7947.615 1
    8 2005 "15"  50478552  5230  9651.731 1
    8 2006 "15"  51174140  5503  9299.317 1
    8 2007 "15"  65760408  6532 10067.423 1
    8 2008 "15"  75889648  6243 12155.958 1
    8 2009 "15"  69684768  6832  10199.76 1
    8 2010 "15"  76790928  7208  10653.57 1
    8 2011 "15"  72062648  7804  9234.065 1
    8 2012 "15"  75477424  8202  9202.319 1
    8 2013 "15"  86713528  8784  9871.759 1
    8 2014 "15"  88902760  8970  9911.121 1
    8 2015 "15"  86198296 11287  7636.954 1
    8 2016 "15" 103714640 14582  7112.511 1
    8 2017 "15" 113921072 15307  7442.417 1
    8 2018 "15" 136004384 16373  8306.626 1
    8 2019 "15" 159106672 17273  9211.293 1
    8 2020 "15" 155971456 16480  9464.287 1
    8 1995 "16"         .   976         . 1
    8 1996 "16"         .  2148         . 1
    8 1997 "16"         .  1946         . 1
    8 1998 "16"         .  1399         . 1
    8 1999 "16"         .  1137         . 1
    8 2000 "16"   2835555   899  3154.121 1
    8 2001 "16"   2138344   546  3916.381 1
    8 2002 "16"   1191542   418  2850.579 1
    8 2003 "16"   1178961   374  3152.302 1
    8 2004 "16"   -127729   253         . 1
    8 2005 "16"   1404002   240  5850.008 1
    8 2006 "16"    876463   188  4662.037 1
    8 2007 "16"    983944   174  5654.851 1
    8 2008 "16"    520534   147 3541.0476 1
    8 2009 "16"    620027   123   5040.87 1
    8 2010 "16"   1208274   185  6531.211 1
    8 2011 "16"   1432824   104 13777.154 1
    8 2012 "16"    628974    92  6836.674 1
    8 2013 "16"   -312428   144         . 1
    8 2014 "16"   1327702   273 4863.3774 1
    8 2015 "16"         .     .         . 1
    8 2016 "16"         .     .         . 1
    8 2017 "16"         .     .         . 1
    8 2018 "16"         .     .         . 1
    8 2019 "16"         .     .         . 1
    8 2020 "16"         .     .         . 1
    8 1995 "17"         .   172         . 1
    8 1996 "17"         .   106         . 1
    8 1997 "17"         .   960         . 1
    8 1998 "17"         . 10082         . 1
    8 1999 "17"         .  8223         . 1
    8 2000 "17"  14949528  8717 1714.9855 1
    8 2001 "17"  17252980  8562 2015.0642 1
    8 2002 "17"  25635992 11638 2202.7832 1
    8 2003 "17"  28142036 10479  2685.565 1
    8 2004 "17"  29246026 10213  2863.608 1
    8 2005 "17"  33258012 10018 3319.8254 1
    8 2006 "17"  37106828  9807  3783.708 1
    8 2007 "17"  56726600 12639  4488.219 1
    8 2008 "17"  70314784 13162  5342.257 1
    8 2009 "17"  60823208 11845  5134.927 1
    8 2010 "17"  66085984 14105 4685.2876 1
    8 2011 "17"  73213304 14172  5166.053 1
    8 2012 "17"  78955832 15088  5233.022 1
    8 2013 "17"  89212400 15873  5620.387 1
    8 2014 "17" 107036280 18485   5790.44 1
    8 2015 "17"   6424091   981  6548.513 1
    8 2016 "17"   5398844   991  5447.875 1
    8 2017 "17"   8043661  1449  5551.181 1
    8 2018 "17"  11732658  1943  6038.424 1
    8 2019 "17"  12080018  2274  5312.233 1
    8 2020 "17"  11841980  2170  5457.134 1
    8 1995 "18"         .  1532         . 1
    8 1996 "18"         .  2243         . 1
    8 1997 "18"         .  1623         . 1
    8 1998 "18"         .     .         . 1
    8 1999 "18"         .     .         . 1
    8 2000 "18"         .     .         . 1
    8 2001 "18"         .     .         . 1
    8 2002 "18"         .     .         . 1
    8 2003 "18"         .     .         . 1
    8 2004 "18"         .     .         . 1
    8 2005 "18"         .     .         . 1
    8 2006 "18"         .     .         . 1
    8 2007 "18"         .     .         . 1
    8 2008 "18"         .     .         . 1
    8 2009 "18"         .     .         . 1
    8 2010 "18"         .     .         . 1
    8 2011 "18"         .     .         . 1
    8 2012 "18"         .     .         . 1
    8 2013 "18"         .     .         . 1
    8 2014 "18"         .     .         . 1
    8 2015 "18"  78066320 19550  3993.162 1
    8 2016 "18"  92327672 23083 3999.8125 1
    end
    And I would like to know how I can obtain a variable that describes the ratio between value added per worker by tech intensity in a particular year over the average value added per worker of all tech intensities in that year (and also over the median value added per worker)

    For instance, I want to know the ratio of value added per worker in tech intensity==1 in year 1989 over average value added per worker in year 1989 (the same for all years, and also for the median)

    Thank you very much,

  • #2
    I was thinking something on these lines

    Code:
     bysort tech_intensity year: egen y_tech= mean(val_per_worker)
    Code:
     bysort year: egen y_year= mean(val_per_worker)
    Code:
     gen ratio= (y_tech)/(y_yea)r
    Would that be correct for the case of the average?


    Comment

    Working...
    X