Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int(clientid partnerid year) byte indyear double industry_share_ep    byte    spec
1081    7 2014  7 .0048005590215325356 7
1324   15 2014  7  .005018132273107767 5
628   33 2014  7 .0036202515475451946 9
1103   41 2014  7  .012695363722741604 2
792   41 2014  7  .012695363722741604 2
504   46 2014  7  .006923461798578501 4
617   48 2014  7  .004891650751233101 6
1203   48 2014  7  .004891650751233101 6
1054   54 2014  7  .020323878154158592 1
487   58 2014  7  .004543224349617958 8
74   59 2014  7  .007345101330429316 3
1279    4 2015  8  .004082599189132452 .
1081    7 2015  8  .005235201679170132 .
628   33 2015  8  .003987567033618689 .
792   41 2015  8  .012957603670656681 .
1103   41 2015  8  .012957603670656681 .
1203   48 2015  8  .005978947039693594 .
617   48 2015  8  .005978947039693594 .
627   58 2015  8  .017269672825932503 .
1096   58 2015  8  .017269672825932503 .
504   58 2015  8  .017269672825932503 .
487   58 2015  8  .017269672825932503 .
599   58 2015  8  .017269672825932503 .
74   59 2015  8  .007718401029706001 .
1165   66 2015  8  .005468184128403664 .
190   86 2015  8   .03738570585846901 .
453   86 2015  8   .03738570585846901 .
526   88 2015  8  .005846200976520777 .
490 1089 2016  9   .02829659730195999 .
253 1089 2016  9   .02829659730195999 .
997 1093 2016  9  .008093434385955334 .
1490 1093 2016  9  .008093434385955334 .
1081 1100 2016  9 .0054756589233875275 .
948 1109 2016  9  .020321520045399666 .
893 1110 2016  9  .005612920969724655 .
1124 1148 2016  9                    0 .
1181 1153 2016  9 .0053636180236935616 .
1260 1164 2016  9                    0 .
1457 1192 2016  9   .01999679021537304 .
868 1205 2016  9  .020531661808490753 .
206 1210 2016  9  .005854192189872265 .
1230 1230 2016  9  .009276914410293102 .
806 1230 2016  9  .009276914410293102 .
724   19 2017 10  .005364460404962301 .
628   33 2017 10  .004450527019798756 .
436   43 2017 10  .004119019955396652 .
617   48 2017 10  .005194490309804678 .
1203   48 2017 10  .005194490309804678 .
490   52 2017 10  .030522581189870834 .
821   52 2017 10  .030522581189870834 .
285   54 2017 10  .024143129587173462 .
633   57 2017 10 .0068115307949483395 .
751   58 2017 10   .01648836024105549 .
1096   58 2017 10   .01648836024105549 .
627   58 2017 10   .01648836024105549 .
487   58 2017 10   .01648836024105549 .
1165   66 2017 10  .006617478094995022 .
190   86 2017 10   .03865887597203255 .
453   86 2017 10   .03865887597203255 .
994    5 2014 18  .006885720416903496 .
1112   11 2014 18  .016296733170747757 .
478   12 2014 18  .004438069649040699 .
918   22 2014 18  .005527980625629425 .
337   22 2014 18  .005527980625629425 .
49   59 2014 18  .007213207893073559 .
1301   66 2014 18  .005558209028095007 .
1384   84 2014 18  .012285162694752216 .
1133  171 2015 19  .017234930768609047 .
424  191 2015 19  .020662015303969383 .
1164  211 2015 19                    0 .
1162  235 2015 19  .016075843945145607 .
1449  266 2015 19  .016308801248669624 .
318  278 2015 19  .004750378429889679 .
105  289 2015 19   .01624026708304882 .
1561  293 2015 19  .007419430650770664 .
21  306 2015 19  .006908397190272808 .
113  312 2015 19  .017234930768609047 .
352  315 2015 19  .005803853273391724 .
1010  318 2015 19  .005676507484167814 .
279  319 2015 19  .005354285705834627 .
end


Hi All

I kindly request assistance for the above. I am looking to generate a code such that for each 'indyear' : the 'partnerid' with the highest 'industry_share_ep' will have a ranking of 1, and the next 2, in descending order as demonstrated in 'Spec'.

NB: The rankings in spec were done manually to give an idea of what i am seeking to achieve with the code.