Dear all,

I have the following data merged (industry level data and trade at the industry level at the same level of disaggregation). I want to build an index (which has in the literature for a while). And I want to make sure I am using the proper syntax.I posted the index from latex document file.

The data is the following

Code:
 * Example generated by -dataex-. To install: ssc install dataex
clear
input int(country year isic isiccomb) byte sourcecode long(Establishments Employment) double(Wages OutputINDSTAT4 ValueAdded GrossFixed) float(NewImportsWorld NewExportsWorld NewOutput)
752 1990 1511 1511 1  211 18970  410760814  4812639070  750829139         .  205787008  152038000  4812639232
231 1990 1511 1511 0    .     .          .           .          .         .          .          .           .
554 1990 1511 1511 1  250 27670          .           .          .         .   39597000 1904916992           .
 40 1990 1511 1511 1  211 14341  281952246  2648385387  483309907  82419767  173028000  267799008  2648385024
352 1990 1511 1511 0    .     .          .           .          .         .     643000   13263000           .
428 1990 1511 1511 1  273  7176          .     4237801          .         .          .          .     4238000
158 1990 1511 1511 0    .     .          .           .          .         .  454000992  706115008           .
250 1990 1511 1511 0    .     .          .           .          .         . 4090940928 3523758080           .
 44 1990 1511 1511 0    .     .          .           .          .         .          .          .           .
442 1990 1511 1511 0    .     .          .           .          .         .          .          .           .
124 1990 1511 1511 1  633 46651 1127459988 10664004340 2239077148         .  818744000 1248240000 10664003584
332 1990 1511 1511 0    .     .          .           .          .         .          .      40000           .
410 1990 1511 1511 1  242 14578  113690412  1294216411  411153903  80461830 1689671936   70361000  1294215936
776 1991 1511 1511 0    .     .          .           .          .         .          .          .           .
 44 1991 1511 1511 0    .     .          .           .          .         .          .          .           .
352 1991 1511 1511 0    .     .          .           .          .         .     840000    6164000           .
158 1991 1511 1511 0    .     .          .           .          .         .  525063008 1046316032           .
702 1991 1511 1511 1   17   584    5668143    29826054   15814303   5500854  237994000          .    29826000
703 1991 1511 1511 1   44 12891   20219157   497778004          .         .          .          .   497777984
246 1991 1511 1511 0    .     .          .           .          .         .   30361000   70059000           .
554 1991 1511 1511 1  250 27670          .           .          .         .   30491000 1920531968           .
372 1991 1511 1511 1  144 12028  199582956  3536149122  581041597  77257141  176370000 1552030976  3536148992
410 1991 1511 1511 1  268 13471  118579948  1592683837  522258484 122523477 1717752960   56953000  1592684032
250 1991 1511 1511 0    .     .          .           .          .         . 3985878016 3657634048           .
332 1991 1511 1511 0    .     .          .           .          .         .          .          0           .
578 1991 1511 1511 1  218 10305  294456237  3430694979  385781581  55221834   28105000   32967000  3430694912
752 1991 1511 1511 1  203 18243  401262876  4286257370  733530253         .  223212000   94554000  4286256896
 40 1991 1511 1511 1  197 14498  303395178  2877601494  518726611  90747131  148488992  214368992  2877601024
428 1991 1511 1511 1  308  6998          .    13002620          .         .          .          .    13003000
231 1991 1511    . 1    7  3663    3963285    41919807   18216908    576812          .          .    41920000
442 1991 1511 1511 0    .     .          .           .          .         .          .          .           .
276 1991 1511 1511 0    .     .          .           .          .         . 5809546752 3660185088           .
124 1991 1511 1511 1  608 44994 1139846700 10260858181 2315482061         .  883571968 1078050048 10260857856
710 1991 1511 1511 1  282 25743  151775151   973095427  326538624         .          .          .   973094976
703 1992 1511 1511 1   44 11804   20555460   442950701          .         .          .          .   442951008
380 1992 1511 1511 1  487 40073 1598169003 14880936757 2621584081 429854678 5494322176 1119657984 14880936960
776 1992 1511 1511 0    .     .          .           .          .         .          .          .           .
578 1992 1511 1511 1  156  9938  310083625  3518866599  429479374  44734082   33248000   44994000  3518866944
410 1992 1511 1511 1  301 16275  159169753  1807466207  669953810 140485343 1658217984   85798000  1807465984
590 1992 1511 1511 1   29  1844    7130000    94010000    7002000   5813000          .          .    94010000
792 1992 1511 1511 1  102 11338   89348079  1091967404  256402794  27211874  235286000   57520000  1091966976
352 1992 1511 1511 0    .     .          .           .          .         .    1083000    6734000           .
246 1992 1511 1511 0    .     .          .           .          .         .   39316000   76060000           .
702 1992 1511 1511 1   18   689    7281302    43691493   19426422  10394317  241943008          .    43691000
250 1992 1511 1511 0    .     .          .           .          .         . 4353823232 4323734016           .
616 1992 1511 1511 0    .     .          .           .          .         .  173932992  251923008           .
372 1992 1511 1511 1  152 12912  236507239  3893002632  598923688  64656443  195820000 1894761984  3893003008
417 1992 1511 1511 1  126  4690    2184146    53954268          .         .          .          .    53954000
 40 1992 1511 1511 1  197 14296  342939911  3218480128  588420953 101987715  163900992  234464000  3218480128
762 1992 1511 1511 1   38  1911          .     4038072          .    222762          .          .     4038000
554 1992 1511 1511 1  253 27510          .           .          .         .   36465000 1972987008           .
428 1992 1511 1511 1  164  9916          .    72852289          .         .          .          .    72852000
442 1992 1511 1511 0    .     .          .           .          .         .          .          .           .
124 1992 1511 1511 1  588 46848 1150764898  9753177527 2360765039         .  865473984 1210505984  9753178112
332 1992 1511 1511 0    .     .          .           .          .         .          .          .           .
 44 1992 1511 1511 0    .     .          .           .          .         .          .          .           .
208 1992 1511 1511 1    .     .          .  6926130024 1673933460 191667248  363102016 4078067968  6926130176
232 1992 1511 1511 1    2   665     407491     2568297    1205004         0          .          .     2568000
158 1992 1511 1511 0    .     .          .           .          .         .  507337984 1074740992           .
752 1992 1511 1511 1  206 16860  437292072  4456000026  841885404         .  294567008   96473000   4.456e+09
276 1992 1511 1511 0    .     .          .           .          .         . 7119265792 3176626944           .
440 1992 1511 1511 1    . 13840    6932730   162210090          .         .    1064000   59887000   162210000
231 1992 1511    . 1    7  3221    2732917     9003390    3226405    101338          .          .     9003000
496 1992 1511 1511 1    6  2402    2416744    55967442   17935814  16579535          .          .    55967000
710 1992 1511 1511 1    .     .          .  1155665786          .         .  110301000  166346000  1155666048
 36 1993 1511 1511 1  645 46391          .  6255440104 1832635187         .   46923000 3161800960  6255439872
762 1993 1511 1511 1   99  1660          .    10427730          .   2533552          .          .    10428000
300 1993 1511 1511 0    .     .          .           .          .         .  797523008   52119000           .
702 1993 1511 1511 1   19   764    8769080    57363855   22139002   2611724  235638000   47758000    57364000
554 1993 1511 1511 1  268 28710          .           .          .         .   48869000 2014814976           .
578 1993 1511 1511 1  155 10057  283206578  3052464792  327553531  55020567   46533000   36922000  3052464896
332 1993 1511 1511 0    .     .          .           .          .         .          .          .           .
590 1993 1511 1511 1   29  1853   10127000    90596000   18053000   7148000          .          .    90596000
703 1993 1511 1511 1   49 11578   22164747   356065938   54859374  21066227          .          .   356065984
 40 1993 1511 1511 1  192 14408  332735622  2959263196  560602833 106450231  145410000  212484992  2959262976
442 1993 1511 1511 0    .     .          .           .          .         .          .          .           .
208 1993 1511 1511 1  342     .          .  5733148322 1647420341 161574160  349519008 3530907904  5733148160
158 1993 1511 1511 0    .     .          .           .          .         .  495086016 1113870976           .
428 1993 1511 1511 1  224  8107    7083167   113632597   28508877   2393336          .          .   113633000
380 1993 1511 1511 1  519 40676 1320163744 12029462504 2126914231 361138745 4497477120  912947968 12029462528
792 1993 1511 1511 1  102 11624   92944925  1231588530  303413746  15475649  289539008   50670000  1231588992
232 1993 1511 1511 1    2   379     337303      918390     444808         0          .          .      918000
231 1993 1511    . 1    7  3152    2121600     7378200    3182200     78400          .          .     7378000
440 1993 1511 1511 1   19 12286    7873732   177247834          .         .          .          .   177248000
276 1993 1511 1511 0    .     .          .           .          .         . 5450384896 2676812032           .
352 1993 1511 1511 0    .     .          .           .          .         .     590000    5244000           .
398 1993 1511 1511 1 1304     .          .   4.096e+08          .         .          .          .   4.096e+08
 32 1993 1511 1511 1 1079 45728  554246175  4612161218  914363739 153194467  150990000  791281024  4612161024
616 1993 1511 1511 0    .     .          .           .          .         .  225496000  189412000           .
724 1993 1511 1511 1 3079 58797  933848554 10418448822 1860357115 313765688  958025024  447728992 10418449408
496 1993 1511 1511 1    5  2242     717940    17164811    5290320   2496860          .          .    17165000
116 1993 1511 1511 0    .     .          .           .          .         .          .          .           .
826 1993 1511 1511 1 1579 79875 1900242517 14566026303 3259058398 451438830 3064681984 1592034048 14566026240
776 1993 1511 1511 0    .     .          .           .          .         .          .          .           .
246 1993 1511 1511 0    .     .          .           .          .         .   32308000   77148000           .
124 1993 1511 1511 1  574 47010 1062780989  9715377556 2127536261         .  942958976 1343789056  9715378176
752 1993 1511 1511 1  202 16453  333976666  3409937551  600378214         .  201392000  111792000  3409937920
417 1993 1511 1511 1  158  4169     709576    22061175          .         .          .          .    22061000
372 1993 1511 1511 1  153 13041  212624531  3533411479  561092834  75305054  124006000 1791170048  3533411072
512 1993 1511 1511 1    1     1       1560       14044       8270         .   70760000          .       14000
end
------------------ copy up to and including the previous line ------------------

In order to calculate the first term of the index (Skit) = VAkit/GDPit, I am using the following syntax (k industry, i country, t year). VAkit would be Value added per industry k in country i in year t

sort country isic year

by country isic year: egen TotalOutput_sector= sum(OutputINDSTAT4)

sort isic year country

by isic year country: egen TotalValueAdded=sum(ValueAdded)

gen tradability_one= TotalValueAdded/OutputINDSTAT4



In order to calculate the second term of the index (Dkt)= Xkt/WGDPkt, I am using the following syntax (k is industry, t year). Xkt would be total exports by industry (isic) on a particular year. For WGDPkt (World Total Output), I am using total output of industry k in year t

sort isic year

by isic year: egen TotalExports= sum(NewExportsWorld) if NewExportsWorld!=. //(To avoid having shares greater than 1)

sort isic year

by isic year: egen TotalOutput= sum(NewOutput) if NewOutput!=. //(To avoid having shares greater than 1)

gen tradability_output= Totalexports/TotalOutput_sector



Finally, to calculate the final index, I am doing

gen share= tradability_output*tradability_one


The reason of my question is the fact that I am getting extremely strange values in my sample

Thank you so much,