- * Example generated by -dataex-. To install: ssc install dataex
- clear
- input str12 stkcd str18 year str78 Position str21 StartDate
- "000002" "2007" "执行副总裁" "20010215"
- "000002" "2007" "总裁" "20010215"
- "000002" "2007" "副总经理" "20050728"
- "000002" "2007" "执行副总裁" "20041026"
- "000002" "2007" "执行副总裁" "20040804"
- "000002" "2007" "执行副总裁" "20071026"
- "000002" "2007" "执行副总裁" "20021207"
- "000002" "2007" "执行副总裁" "20040305"
- "000002" "2007" "执行副总裁" "20071026"
- "000002" "2008" "执行副总裁" "20021207"
- "000002" "2008" "执行副总裁" "20071026"
- "000002" "2008" "执行副总裁" "20040804"
- "000002" "2008" "副总经理" "20050728"
- "000002" "2008" "执行副总裁" "20041026"
- "000002" "2008" "执行副总裁" "20071026"
- "000002" "2008" "执行副总裁" "20040305"
- "000002" "2008" "总裁" "20010215"
- "000002" "2008" "执行副总裁" "20010215"
- end
我需要产生一个新变量,得到每一家公司,每个年度的总裁的StartDate减去同一年度的单个非总裁的StartDate。因为截取的是部分数据,在其他公司里面Position可能是总裁,也可能是总经理,也可能是CEO。请问该怎么编程?