Hi,

I want to generate a new variable (RC) with the sum of industry-year (-Risky_Ind- and -year-) adjusted -INV- and -REC- as a percentage of -TA-, and expressed as deviation from the corresponding industry-year mean.

I would be grateful if you could help me with generating the new variable.

Note: IS is the company identifier.

example:

. dataex IS INV REC TA year risky_ind in 1/50

----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str11 IS double(INV REC TA) int year float risky_ind
"IQ1001135"     2.20403  2.52538   42.87435 2013 0
"IQ1001135"     2.83681   3.1106   24.37639 2014 0
"IQ10038253"   10.03707  9.87853   67.32937 2017 0
"IQ100475337" 140.42434 64.60702 1320.80513 2013 0
"IQ100475337"  95.74748 65.44843  857.81385 2014 0
"IQ100475337"  53.54069  52.1743  574.70545 2015 0
"IQ100475337"  58.86901  38.4869  501.58682 2016 0
"IQ100475337"  46.88747 37.78913  427.04402 2017 0
"IQ100475337"  17.20336 47.58633  450.97572 2018 0
"IQ10059716"   13.97032  2.20655   64.91229 2014 0
"IQ10059716"   12.58804  1.39677   79.95269 2015 0
"IQ10059716"   13.46922  1.33011   71.59447 2016 0
"IQ10059716"   15.93507  2.52412   76.18798 2017 0
"IQ10059716"   16.80082  1.94413   83.10289 2018 0
"IQ100601859"  59.32227 15.65512  200.16184 2013 0
"IQ100601859"  69.46581   9.0277  250.01989 2014 0
"IQ100601859"   76.5801 13.21964  289.17414 2015 0
"IQ100601859"  57.17937  9.38205  265.69254 2016 0
"IQ100601859"  45.53861  6.08402  329.99212 2017 0
"IQ100601859"  41.12032  5.39557  338.10262 2018 0
"IQ10063218"     .10101   .55322   16.63223 2016 0
"IQ10063218"     .13055  1.21617   18.80271 2017 0
"IQ10063218"     .09417  1.42922   15.64643 2018 0
"IQ1007880"        44.6    175.1     3016.5 2014 0
"IQ1007880"        39.5    168.1     2765.1 2015 0
"IQ102377327"    16.528    7.584     63.839 2013 0
"IQ102377327"    12.146    3.755     40.429 2014 0
"IQ102377327"    10.037    3.182     29.465 2015 0
"IQ102377327"    12.977    3.546     35.056 2016 0
"IQ102377327"    19.175    3.427     66.001 2018 0
"IQ1027520"      .13204 39.70413  174.29746 2013 1
"IQ1027520"      .10263 40.96519  164.38773 2014 1
"IQ1027520"       .1358  47.1315  206.26628 2015 1
"IQ1027520"       .1389 44.97404   207.2047 2016 1
"IQ1027520"      .10174 54.73586  267.06623 2017 1
"IQ1027520"      .09828 58.96796  302.21079 2018 1
"IQ10332217"    3.54973    3.542   10.19086 2013 0
"IQ10332217"     4.0283   3.5752   11.44259 2014 0
"IQ10332217"    4.58241  3.68841   12.71978 2015 0
"IQ10332217"    5.49894   4.2628   14.14477 2016 0
"IQ10332217"    4.99721  4.58772   15.03865 2017 0
"IQ10332217"    4.97193  4.85585   16.30446 2018 0
"IQ1034090"           .    348.4     1094.6 2013 0
"IQ1034090"           .    326.1     1031.5 2014 0
"IQ1034090"           .    300.8     1086.3 2015 0
"IQ1034090"           .    339.8     1074.5 2016 0
"IQ1034090"           .    364.9     1149.9 2017 0
"IQ1034090"           .    335.4     1197.6 2018 0
"IQ1034269"       2.198    1.781     18.498 2013 0
"IQ1034269"        .067     .465       7.56 2014 0
end
------------------ copy up to and including the previous line ------------------

Listed 50 out of 4887 observations

.



Best,
Mahmoud