目的:计算每个人经历过多少个职位
原始数据:
姓名 | Position1 | Position2 | Position3 | Position4 | Position5 | 期望的统计结果 |
张三 | 副主任科员 | 主任科员 | 副处长 | 3 | ||
李四 | 副司长 | 司长 | 2 | |||
王五 | 财务部副总经理 | 总经理 | 董事长助理 | 董事长 | 常务董事 | 5 |
赵六 | 副总经理 | 总经理 | 3 | |||
马七 | 业务经理 | 1 | ||||
赵二 | 副总经理 | 总经理 | 2 |
我的代码:
data tmp2;
set tmp1;
if position1~="" and position2="" then count=1;
else if position2~="" and position3="" then count=2;
else if position3~="" and position4="" then count=3;
else if position4~="" and position5="" then count=4;
else if position5~="" then count=5;
run;
主要的疑问:
使用Macro test;% do i=1 %to 5;
只能表示&i.的概念,难以表示&i.+1的概念