Hi!

I have the following data (dataex below) and I just want to confirm if I am doing the right approach given what I want to find. Initially, I want to group all variables in the dataex by country, category (tech_intensity), and year. Therefore, I did the following command

Code:
 collapse Establishments Employment share_emp Wages OutputINDSTAT4 ValueAdded GrossFixed r_valworker r_output_worker lval_per_worker ln_1980  perc_wanted2, by(country1 tech_intensity year)
The main purpose is to later create variables for each of the grouping variables .For instance, r_valworker_high, r_valworker_low, r_valworker_medium, ln_1980_high, ln_1980_low, ln_1980_medium... I do this by doing the following (for the variable share_emp)

Code:
 by year country1 (tech_intensity), sort: assert tech_intensity == _n
by year country1(tech_intensity): gen share_emp_high = share_emp[3]
by year country1(tech_intensity): gen share_emp_medium = share_emp[2]
by year country1(tech_intensity): gen share_emp_low = share_emp[1]
And, at the end, I group all variables (collapse) by country1 and year. My end goal is to merge this new dataset with World Development Indicators (WDI) data... Am I doing the right steps? Thank you very much!


Code:
 * Example generated by -dataex-. To install: ssc install dataex
clear
input int(country1 year) float(tech_intensity share_emp perc_wanted2 ln_1980 lval_per_worker) long Employment double(Wages OutputINDSTAT4)
4 1973 1  .05658884 . 0 .  1287 . .
4 1973 1          0 . 0 .     0 . .
4 1973 1    .552038 . 0 . 12555 . .
4 1973 1          0 . 0 .     0 . .
4 1973 1  .18999253 . 0 .  4321 . .
4 1973 1  .03187794 . 0 .   725 . .
4 1973 1          . . 0 .     . . .
4 1973 1  .08534494 . 0 .  1941 . .
4 1974 1          0 . 0 .     0 . .
4 1974 1   .5064898 . 0 . 14243 . .
4 1974 1  .04715337 . 0 .  1326 . .
4 1974 1  .02560364 . 0 .   720 . .
4 1974 1          0 . 0 .     0 . .
4 1974 1  .17229117 . 0 .  4845 . .
4 1974 1  .07268589 . 0 .  2044 . .
4 1974 1          . . 0 .     . . .
4 1975 1  .04365534 . 0 .  1447 . .
4 1975 1          0 . 0 .     0 . .
4 1975 1   .5189766 . 0 . 17202 . .
4 1975 1          0 . 0 .     0 . .
4 1975 1   .1539552 . 0 .  5103 . .
4 1975 1  .07002353 . 0 .  2321 . .
4 1975 1          . . 0 .     . . .
4 1975 1  .02636819 . 0 .   874 . .
4 1976 1          0 . 0 .     0 . .
4 1976 1  .56875193 . 0 . 20520 . .
4 1976 1  .02328224 . 0 .   840 . .
4 1976 1  .06422018 . 0 .  2317 . .
4 1976 1  .04060534 . 0 .  1465 . .
4 1976 1          . . 0 .     . . .
4 1976 1  .12583497 . 0 .  4540 . .
4 1976 1          0 . 0 .     0 . .
4 1977 1          0 . 0 .     0 . .
4 1977 1          . . 0 .     . . .
4 1977 1  .05816822 . 0 .  2240 . .
4 1977 1  .16383183 . 0 .  6309 . .
4 1977 1   .5333818 . 0 . 20540 . .
4 1977 1          0 . 0 .     0 . .
4 1977 1  .02389052 . 0 .   920 . .
4 1977 1  .04536602 . 0 .  1747 . .
4 1978 1          0 . 0 .     0 . .
4 1978 1          . . 0 .     . . .
4 1978 1          0 . 0 .     0 . .
4 1978 1  .04207927 . 0 .  1772 . .
4 1978 1    .152288 . 0 .  6413 . .
4 1978 1  .02355679 . 0 .   992 . .
4 1978 1   .5435397 . 0 . 22889 . .
4 1978 1  .06133789 . 0 .  2583 . .
4 1979 1  .05224232 . 0 .  2218 . .
4 1979 1   .5590023 . 0 . 23733 . .
4 1979 1          . . 0 .     . . .
4 1979 1 .021174863 . 0 .   899 . .
4 1979 1  .05949689 . 0 .  2526 . .
4 1979 1   .1414641 . 0 .  6006 . .
4 1979 1          0 . 0 .     0 . .
4 1979 1          0 . 0 .     0 . .
4 1980 1          0 . 0 .     0 . .
4 1980 1          . . 0 .     . . .
4 1980 1   .1470306 . 0 .  5672 . .
4 1980 1  .06897893 . 0 .  2661 . .
4 1980 1          0 . 0 .     0 . .
4 1980 1  .05783239 . 0 .  2231 . .
4 1980 1  .52979755 . 0 . 20438 . .
4 1980 1 .019908236 . 0 .   768 . .
4 1981 1          . . 0 .     . . .
4 1981 1  .01993137 . 0 .   697 . .
4 1981 1  .24252217 . 0 .  8481 . .
4 1981 1          0 . 0 .     0 . .
4 1981 1  .09917071 . 0 .  3468 . .
4 1981 1   .4308836 . 0 . 15068 . .
4 1981 1 .063768946 . 0 .  2230 . .
4 1981 1          0 . 0 .     0 . .
4 1982 1  .22308142 . 0 .  6866 . .
4 1982 1 .018974593 . 0 .   584 . .
4 1982 1  .05880824 . 0 .  1810 . .
4 1982 1   .4349535 . 0 . 13387 . .
4 1982 1  .10432777 . 0 .  3211 . .
4 1982 1          0 . 0 .     0 . .
4 1982 1          . . 0 .     . . .
4 1982 1          0 . 0 .     0 . .
4 1983 1 .033794936 . 0 .   942 . .
4 1983 1          . . 0 .     . . .
4 1983 1 .005632489 . 0 .   157 . .
4 1983 1  .07085456 . 0 .  1975 . .
4 1983 1  .12796871 . 0 .  3567 . .
4 1983 1   .1822487 . 0 .  5080 . .
4 1983 1          0 . 0 .     0 . .
4 1983 1   .3611609 . 0 . 10067 . .
4 1984 1 .005718865 . 0 .   157 . .
4 1984 1  .14854479 . 0 .  4078 . .
4 1984 1   .1889411 . 0 .  5187 . .
4 1984 1 .034568172 . 0 .   949 . .
4 1984 1  .04498598 . 0 .  1235 . .
4 1984 1   .3718355 . 0 . 10208 . .
4 1984 1          0 . 0 .     0 . .
4 1984 1          . . 0 .     . . .
4 1985 1   .3619766 . 0 . 10468 . .
4 1985 1  .06995401 . 0 .  2023 . .
4 1985 1          0 . 0 .     0 . .
4 1985 1          . . 0 .     . . .
end