楼主: yangz98
1895 12

[有偿编程] 相邻年间转移次数的统计 [推广有奖]

11
龙潭丰乐 学生认证  发表于 2013-11-3 21:05:27 |只看作者 |坛友微信交流群
yangz98 发表于 2013-11-2 22:54
跑了一遍貌似答案不太对。。。
我也一木有想明白,lag(site)*site是什么意思?
lag是指滞后一期嘛  所以就是前一项啊

使用道具

12
yangz98 发表于 2013-11-4 12:39:53 |只看作者 |坛友微信交流群
邓贵大 发表于 2013-11-2 12:25
Sorry, I didn't test my code.
Change 'if eof' to 'if _n_=12' or use a second data step. Didn't real ...
修改后有跑了几次,发现结果不对。。。

使用道具

13
邓贵大 发表于 2013-11-4 21:58:53 |只看作者 |坛友微信交流群
yangz98 发表于 2013-11-4 12:39
修改后有跑了几次,发现结果不对。。。
Dude, now I kind regret that I had wanted your easy bucks in the first place. Isn't God's love enough for me? Why would I want these fake Lun Tan Bi? There's something wrong in my soul. I got to quit for a few months.
  1. data quextion;
  2.         infile datalines eof=last;
  3.         input year site;
  4.         array x[5,5] _temporary_;
  5.         array a[5];
  6.         site_1=lag(site);
  7.         if _n_=1 then call pokelong(repeat(put(0,rb8.), 25), addrlong(x[1,1]), 25*8);
  8.         else x[site_1, site] = x[site_1, site]+1;
  9.         last:
  10.                 do i=1 to 5;
  11.                         do j=1 to 5;
  12.                                 a[j] = x[i,j];
  13.                         end;
  14.                         output;
  15.                 end;
  16.         keep a1-a5;
  17. cards;
  18. 1980 5
  19. 1981 1
  20. 1982 2
  21. 1983 2
  22. 1984 1
  23. 1985 2
  24. 1986 1
  25. 1987 3
  26. 1988 1
  27. 1989 3
  28. 1990 2
  29. 1991 1
  30. 1992 3
  31. 1993 3
  32. 1994 4
  33. 1995 4
  34. 1996 5
  35. 1997 5
  36. 1998 5
  37. 1999 4
  38. 2000 4
  39. 2001 1
  40. ;
复制代码
  1. data quextion;
  2.         infile datalines;
  3.         input year site;
  4. cards;
  5. 1980 5
  6. 1981 1
  7. 1982 2
  8. 1983 2
  9. 1984 1
  10. 1985 2
  11. 1986 1
  12. 1987 3
  13. 1988 1
  14. 1989 3
  15. 1990 2
  16. 1991 1
  17. 1992 3
  18. 1993 3
  19. 1994 4
  20. 1995 4
  21. 1996 5
  22. 1997 5
  23. 1998 5
  24. 1999 4
  25. 2000 4
  26. 2001 1
  27. ;
  28. data q/view=q;
  29.         set quextion;
  30.         site_1= lag(site);
  31.         keep site_1 site;
  32. proc means data=q nway noprint completetypes;
  33.         class site_1 site;
  34.         output out=q1;
  35. proc transpose data=q1 out=anxwer(drop=_name_ _label_) prefix=a;
  36.         by site_1;
  37.         id site;
  38.         var _freq_;
  39. run;
复制代码
Final word, Dywane, you're doing a heck great of job on the basketball court. I wish you success in SAS too.
Be still, my soul: the hour is hastening on
When we shall be forever with the Lord.
When disappointment, grief and fear are gone,
Sorrow forgot, love's purest joys restored.

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-28 14:27