楼主: 少呃
5100 12

求助!关于SAS中产生随机数的问题 [推广有奖]

11
dybwall1234 发表于 2010-3-14 03:15:43
jingju11 发表于 2010-3-13 22:32


Really? I run it about 3-5 minutes and had no obvious problem. About the temporary files, I don't get it. Can you list it out? If you had better way to do that, why don't share it?
几个同学都试了 都太卡所以中止了 生成大量临时文件 同学已作出一个比较麻烦但可行的方法了 分享给大家吧
  1. data test;
  2. do i=1 to 5000;
  3. retain seed  185634382;
  4. call ranuni(seed,random);
  5. output;
  6. end;
  7. run;
  8. data a(drop=seed i B PB c1 d1 e1 f1 g1 h1 j1 k1 l1 c d e f g h j k l);
  9. do i=1 to 5000;
  10. B=INT(1+26*uniform(0));
  11. if B=1 THEN PB='A' ;
  12. if B=2 THEN PB='B' ;
  13. if B=3 THEN PB='C' ;
  14. if B=4 THEN PB='D' ;
  15. if B=5 THEN PB='E' ;
  16. if B=6 THEN PB='F' ;
  17. if B=7 THEN PB='G' ;
  18. if B=8 THEN PB='H' ;
  19. if B=9 THEN PB='I' ;
  20. if B=10 THEN PB='J' ;
  21. if B=11 THEN PB='K' ;
  22. if B=12 THEN PB='L' ;
  23. if B=13 THEN PB='M' ;
  24. if B=14 THEN PB='N' ;
  25. if B=15 THEN PB='O' ;
  26. if B=16 THEN PB='P' ;
  27. if B=17 THEN PB='Q' ;
  28. if B=18 THEN PB='R' ;
  29. if B=19 THEN PB='S' ;
  30. if B=20 THEN PB='T' ;
  31. if B=21 THEN PB='U' ;
  32. if B=22 THEN PB='V' ;
  33. if B=23 THEN PB='W' ;
  34. if B=24 THEN PB='X' ;
  35. if B=25 THEN PB='Y' ;
  36. if B=26 THEN PB='Z' ;
  37. c=INT(0+9*uniform(0));
  38. c1=put(c,1.);
  39. d=INT(0+9*uniform(0));
  40. d1=put(d,1.);
  41. e=INT(0+9*uniform(0));
  42. e1=put(e,1.);
  43. f=INT(0+9*uniform(0));
  44.   f1=put(f,1.);
  45. g=INT(0+9*uniform(0));
  46.   g1=put(g,1.);
  47. h=INT(0+9*uniform(0));
  48.   h1=put(h,1.);
  49. j=INT(0+9*uniform(0));
  50.   j1=put(j,1.);
  51. k=INT(0+9*uniform(0));
  52.   k1=put(k,1.);
  53. l=INT(0+9*uniform(0));
  54.   l1=put(l,1.);
  55. ID=PB||c1||d1||e1||f1||g1||h1||j1||k1||l1;
复制代码


这个是主体部分 还需加点代码才能运行成功

12
jingju11 发表于 2010-3-14 09:57:21
11# dybwall1234

Thanks you.程序很好。

13
lqwoailuo 发表于 2013-11-15 09:43:53

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-29 22:10