我想按股票代码和年份分组,生成一个新变量,每个公司每年从小到大依次对新变量m赋值为123。。。要怎么写代码呢?求大神指导,如图 第一列是公司股票代码 第二列是年份。stkcd year DA rit zhou rmt wit n
2 2009 .0480404 .029858 24 -.009749 .033848 47
2 2009 .0480404 -.014015 29 .031771 -.0566664 47
2 2009 .0480404 .133333 27 .053061 .0676185 47
2 2009 .0480404 .004354 3 .039168 -.0462109 47
2 2009 .0480404 .051823 41 .049958 -.0041888 47
2 2009 .0480404 -.041518 17 -.028382 -.0148343 47
2 2009 .0480404 -.023967 46 .014444 -.0488631 47
2 2009 .0480404 .110795 6 .085317 .0098792 47
2 2009 .0480404 .001569 33 -.063388 .0713845 47
2 2009 .0480404 -.011331 52 .019753 -.0304997 47
2 2009 .0480404 -.060478 31 .01961 -.0937165 47
2 2009 .0480404 -.06338 39 -.045368 -.0138723 47
2 2009 .0480404 .079654 43 .048307 .0179395 47
2 2009 .0480404 -.101781 51 -.047539 -.0502049 47
2 2009 .0480404 .054475 12 .080097 -.0348225 47
2 2009 .0480404 -.111981 34 -.038741 -.0661139 47
2 2009 .0480404 -.097884 35 -.025379 -.0693284 47
2 2009 .0480404 .160377 19 .061035 .0854209 47
2 2009 .0480404 .091887 36 .001662 .088117 47
2 2009 .0480404 .016949 26 .012459 -.0036517 47
2 2009 .0480404 .057927 20 .003743 .0422631 47
2 2009 .0480404 -.0007 28 .031105 -.0443425 47