Dear all,

I am currently wondering how to achieve the following. I have a country sector year dataset, for which I have data for 10 sectors (a till j), per country and per year. An example of the data:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str8 country int year str4 sector double output
"ARG" 1950 "a"  5578.795678457762
"ARG" 1950 "c"  3162.352961932677
"ARG" 1950 "b" 2192.9547535578636
"ARG" 1950 "f"  8238.906783430726
"ARG" 1950 "d" 13936.542546640336
"ARG" 1950 "e"  687.2856438659917
"ARG" 1950 "g" 2419.9959857454223
"ARG" 1950 "j" 197.88615758071182
"ARG" 1950 "i"  2603.393116487713
"ARG" 1950 "h"   8414.82433396344
"ARG" 1951 "a"  5941.018097253331
"ARG" 1951 "c" 3446.8047678333733
"ARG" 1951 "b" 2223.3408807702936
"ARG" 1951 "f"  8238.906783430726
"ARG" 1951 "d"  14284.57365853503
"ARG" 1951 "e"  763.4055626890308
"ARG" 1951 "g" 2453.5280528148082
"ARG" 1951 "j" 200.62811746295333
"ARG" 1951 "i" 2639.4663798750294
"ARG" 1951 "h"  8531.422235615182
"ARG" 1952 "a" 5257.0737190865775
"ARG" 1952 "c"  2643.523995668816
"ARG" 1952 "b"  2171.336429571928
"ARG" 1952 "f"  8046.196871310385
"ARG" 1952 "d" 13239.524193422663
"ARG" 1952 "e"  750.1673159371979
"ARG" 1952 "g" 2396.1394710683044
"ARG" 1952 "j" 195.93537995524042
"ARG" 1952 "i" 2577.7286581747103
"ARG" 1952 "h"  8331.870320233235
"ARG" 1953 "a"  6740.777451651082
"ARG" 1953 "c" 2510.6175406379525
"ARG" 1953 "b" 2204.7565084567063
"ARG" 1953 "f"  8392.315057867974
"ARG" 1953 "d" 12960.797368297975
"ARG" 1953 "e"  790.2897169516673
"ARG" 1953 "g"  2499.212694571243
"ARG" 1953 "j"  204.3638088735519
"ARG" 1953 "i"  2683.025139817849
"ARG" 1953 "h"  8672.215153443365
"ARG" 1954 "a"  6511.810826255326
"ARG" 1954 "c"  2736.996667338873
"ARG" 1954 "b"  2261.909686839372
"ARG" 1954 "f"  8642.445002404527
"ARG" 1954 "d" 14075.704668796727
"ARG" 1954 "e"  818.2538146284186
"ARG" 1954 "g"  2573.700833823366
"ARG" 1954 "j" 210.45479900277695
"ARG" 1954 "i"   2765.84657411867
"ARG" 1954 "h"  8939.914955027132
"ARG" 1955 "a"  6762.147670021353
"ARG" 1955 "c"  2858.949293658401
"ARG" 1955 "b"  2347.155105444025
"ARG" 1955 "f"  8752.446126472425
"ARG" 1955 "d" 15357.441163895655
"ARG" 1955 "e"   851.081233640257
"ARG" 1955 "g"    2606.4589230743
"ARG" 1955 "j" 213.13346973187592
"ARG" 1955 "i"  2956.088116583164
"ARG" 1955 "h"  9554.823687297538
"ARG" 1956 "a" 6631.4840491288405
"ARG" 1956 "c" 2722.3915623904268
"ARG" 1956 "b" 2394.6213044397973
"ARG" 1956 "f"   9066.33468432222
"ARG" 1956 "d" 15121.438888607598
"ARG" 1956 "e"  880.2611616507802
"ARG" 1956 "g" 2699.9342350769643
"ARG" 1956 "j"  220.7770651881584
"ARG" 1956 "i" 2948.1245171311616
"ARG" 1956 "h"  9529.083321760638
"ARG" 1957 "a"  6745.662072992858
"ARG" 1957 "c"   3229.18870410152
"ARG" 1957 "b"  2420.729413626463
"ARG" 1957 "f"  8881.543149355144
"ARG" 1957 "d" 15877.256520241333
"ARG" 1957 "e"  920.3835626652493
"ARG" 1957 "g" 2727.0119012555233
"ARG" 1957 "j" 223.04791500152234
"ARG" 1957 "i"  3045.111037974143
"ARG" 1957 "h" 10416.063582964312
"ARG" 1958 "a"  6843.354499828381
"ARG" 1958 "c" 3301.4839735963305
"ARG" 1958 "b"  2437.379461120535
"ARG" 1958 "f"  8882.986833222076
"ARG" 1958 "d"  16717.50600036174
"ARG" 1958 "e"  978.7434186862957
"ARG" 1958 "g"  2741.333972622695
"ARG" 1958 "j" 209.92744941319748
"ARG" 1958 "i"  3142.097558817124
"ARG" 1958 "h" 10759.994704655532
"ARG" 1959 "a"   6754.82073800869
"ARG" 1959 "c"  2776.430450699679
"ARG" 1959 "b"  2453.590940306762
"ARG" 1959 "f"   9352.18408997442
"ARG" 1959 "d" 14553.812726492359
"ARG" 1959 "e" 1123.4272284051392
"ARG" 1959 "g" 2750.7400376980886
"ARG" 1959 "j" 201.34868345160044
"ARG" 1959 "i" 3187.2693630453614
"ARG" 1959 "h"  9643.409456394837
end
What I would like to do: Generate a new set of values within the variable sector, which would be the total output of the 10 sectors a till j. I would like to basically generate a new "group" for the sector variable, which would be then letter k, depicting the total output of the sectors per country and per year.

I have seen examples where new variables are generated or values within an existing variable are replaced, which unfortunately cannot be applied to my case as far as I am aware. Any ideas on what I could do to achieve this would be greatly appreciated.

Best,

Satya