楼主: bridge1989
917 2

[学习分享] 想玩斗牛 没有扑克怎么搞?用SAS! [推广有奖]

  • 0关注
  • 1粉丝

讲师

14%

还不是VIP/贵宾

-

威望
0
论坛币
4603 个
通用积分
7.4803
学术水平
7 点
热心指数
7 点
信用等级
5 点
经验
1864 点
帖子
108
精华
0
在线时间
748 小时
注册时间
2013-10-11
最后登录
2024-4-2

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
%let nobs=5;
data test ;call streaminit(0);do i= 1 to &nobs;  u=rand("uniform");  max=10;  x=ceil(max*u);output;end;keep x;run;
proc transpose data=test out=ly;var x;run;
data ly_2;set ly(keep=col1-col5);rename col1=a col2=b col3=c col4=d col5=e;run;
data jg;set ly_2;s1=a+b+c;s2=a+b+d;s3=a+b+e;s4=a+c+d;s5=a+c+e;S6=a+d+e;s7=b+C+D;S8=B+C+E;S9=B+D+E;S10=C+D+E;run;
data jg_1;set jg;
if s1 lt 10 then ; else do;      w1=mod (s1,10);      if w1 eq 0 then R1=1;       else R1=0;     end;
if s2 lt 10 then ; else do;      w2=mod (s2,10);      if w2 eq 0 then R2=1;       else R2=0;     end;
if s3 lt 10 then ; else do;      w3=mod (s3,10);      if w3 eq 0 then R3=1;       else R3=0;     end;
if s4 lt 10 then ; else do;      w4=mod (s4,10);      if w4 eq 0 then R4=1;       else R4=0;     end;
if s5 lt 10 then ; else do;      w5=mod (s5,10);      if w5 eq 0 then R5=1;       else R5=0;     end;
if s6 lt 10 then ; else do;      w6=mod (s6,10);      if w6 eq 0 then R6=1;       else R6=0;     end;
if s7 lt 10 then ; else do;      w7=mod (s7,10);      if w7 eq 0 then R7=1;       else R7=0;     end;
if s8 lt 10 then ; else do;      w8=mod (s8,10);      if w8 eq 0 then R8=1;       else R8=0;     end;
if s9 lt 10 then ; else do;      w9=mod (s9,10);      if w9 eq 0 then R9=1;       else R9=0;     end;
if s10 lt 10 then ; else do;     w10=mod (s10,10);    if w10 eq 0 then R10=1;    else R10=0;     end;
run;
data jg_2;set jg_1;if R1=1 or R2=1 or R3=1 or R4=1 or R5=1 or R6=1 or R7=1 or R8=1 or R9=1 or R10 then zz='有牛';else zz='无牛';run;
data jg_3;set jg_2;
if r1=1 then do; n1=d+e; if n1 le 10 then yu=n1; else yu=n1-10; end;if r2=1 then do; n2=c+e; if n2 le 10 then yu=n2; else yu=n2-10; end;
if r3=1 then do; n3=d+c; if n3 le 10 then yu=n3; else yu=n3-10; end;if r4=1 then do; n4=b+e; if n4 le 10 then yu=n4; else yu=n4-10; end;
if r5=1 then do; n5=d+b; if n5 le 10 then yu=n5; else yu=n5-10; end;if r6=1 then do; n6=c+b; if n6 le 10 then yu=n6; else yu=n6-10; end;
if r7=1 then do; n7=a+e; if n7 le 10 then yu=n7; else yu=n7-10; end;if r8=1 then do; n8=d+a; if n8 le 10 then yu=n8; else yu=n8-10; end;
if r9=1 then do; n9=a+c; if n9 le 10 then yu=n9; else yu=n9-10; end;if r10=1 then do; n10=a+b; if n10 le 10 then yu=n10; else yu=n10-10; end;
wcyn=put (yu,2.);
if zz='有牛' then hh=cats ('牛',wcyn); else hh='无牛,煞笔!';
if a=10 and b=10 and c=10 and d=10 and e=10 then hh='恭喜!!!五花牛!';
if a le 5 and b le 5 and c le 5 and d le 5 and e le 5 then hh='恭喜!!!五小牛!';
keep  hh;run;
proc print data=jg_3 obs;run;


完全可以再优化的,没有时间了 在写炸金花5人场的sas了

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Transpose Uniform output Stream rename

沙发
牵你↗左手 发表于 2014-2-20 14:32:27 |只看作者 |坛友微信交流群
不明觉厉

使用道具

藤椅
Imasasor 发表于 2014-2-20 18:14:23 |只看作者 |坛友微信交流群
不明没觉厉
欢迎加入亚太地区第一R&Python数据挖掘群: 251548215;

使用道具

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

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

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

GMT+8, 2024-4-27 17:41