name month
李磊 201510
李磊 201509
张三 201403
李四 201405
张三 201503
李四 201610
李磊 201301
...... ......
我想将 name 分成三类 分类的依据是month 。第一类 A:name 连续两年每个月都有 第二类 B:name在两年内不连续出现 第三类 C :name在最近一年才有 上一年没有
不知道怎么写 求大神帮助

|
楼主: jasper.jin
|
1883
6
关于根据时间将变量分组问题 |
|
大专生 20%
-
|
回帖推荐you are correct, sorry for my carelessness, please try this one and take a look at if there's any problem, thanks.
proc sort data=a;
by name month;
run;
data consec_month;
set a;
by name month;
mon=month(month);
year=year(month);
lagmon=lag(mon);
lagyear=lag(year);
if first.name then call missing(lagmon,lagyear);
if year=lagyear then num=mon-lagmon;
if year=lagyear+1 and ...
| ||
|
|
| ||
| ||
| ||
|
只有一个罗纳尔多
|
||
加好友,备注cda京ICP备16021002号-2 京B2-20170662号
京公网安备 11010802022788号
论坛法律顾问:王进律师
知识产权保护声明
免责及隐私声明


