楼主: webgu
3554 8

[学习分享] Merry X‘mas 圣诞福利-用SAS画圣诞树 [推广有奖]

贵宾

学科带头人

95%

还不是VIP/贵宾

-

TA的文库  其他...

Python与统计

SAS与统计

威望
2
论坛币
102554 个
通用积分
3.6187
学术水平
475 点
热心指数
493 点
信用等级
434 点
经验
62375 点
帖子
1557
精华
4
在线时间
2201 小时
注册时间
2009-5-4
最后登录
2024-4-23

初级学术勋章 初级热心勋章 初级信用勋章 中级学术勋章 中级热心勋章 中级信用勋章

相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
圣诞快到了,看看SAS大牛(Rick Wicklin)给的圣诞福利吧。
Unnamed QQ Screenshot20121215093014.png

羡慕吧?来玩一把吧,哈哈。

  1. proc iml;
  2. /* Using SAS to construct a Christmas Tree from an iterated function system,
  3.    and adding ornaments and a star.
  4.    Rick Wicklin 12/14/2012
  5.    To construct an iterated function system in SAS, see
  6.    http://blogs.sas.com/content/iml/2012/12/12/iterated-function-systems-and-barnsleys-fern-in-sas/
  7. */
  8. /* 1. Each row is a 2x2 linear transforamtion */
  9. /* Christmas tree */
  10. L = {0.03    0   0    0.1,
  11.      0.85 0.00  0.00 0.85,
  12.      0.8 0.00  0.00 0.8,
  13.      0.2 -0.08  0.15 0.22,
  14.     -0.2  0.08  0.15 0.22,
  15.          0.25 -0.1  0.12 0.25,
  16.     -0.2  0.1  0.12 0.2};
  17. /* ... and each row is a translation vector */
  18. B = {0 0,
  19.      0 1.5,
  20.      0 1.5,
  21.      0 0.85,
  22.      0 0.85,
  23.      0 0.3,
  24.      0 0.4
  25.          };
  26. prob = { 0.02 0.6 0.1 0.07 0.07 0.07 0.07};
  27. /* For convenience, transpose the L and B matrices */
  28. L = L`; B = B`;

  29. /* 3. iterate the discrete stochastic map */
  30. N = 1e5;          /* number of iterations */
  31. x = j(2,N); k = j(N,1);
  32. x[,1] = {0, 2};   /* initial point */
  33. call randseed(1);
  34. call randgen(k, "Table", prob);

  35. do i = 2 to N;
  36.    x[,i] = shape(L[,k[i]], 2)*x[,i-1] + B[,k[i]];
  37. end;

  38. /* 4. plot the iteration history */
  39. y = x`;
  40. create IFS from y[c={"x" "y"}]; append from y; close IFS;

  41. /* just for fun, create ornaments and colors */
  42. idx = ceil(N*ranuni(j(500,1)));
  43. x1 = x[1,idx]`;
  44. jdx = loc(abs(x1)>0.04);
  45. idx = idx[jdx];
  46. x1 = x[1,idx]`;
  47. y1 = x[2,idx]` - 0.1;
  48. group = ceil(5*ranuni(j(nrow(idx),1)));
  49. create Ornaments var {x1 y1 group}; append; close Ornaments;
  50. quit;

  51. /* basic IFS Christmas Tree */
  52. ods graphics / width=200px height=400px;
  53. proc sgplot data=IFS;
  54. title "SAS Christmas Tree";
  55. scatter x=x y=y / markerattrs=(size=1 color=ForestGreen);
  56. yaxis display=none;
  57. xaxis display=none;
  58. run;

  59. /* Add ornaments and star */
  60. data Star;
  61. x2=0; y2=10; output;
  62. run;

  63. data All;
  64. merge IFS Ornaments Star;
  65. if group=. then group=1;
  66. run;

  67. data Attrs;
  68. length Value MarkerColor $20;
  69. ID = "Ornaments";
  70. Value = 1; MarkerColor = "Red    "; output;
  71. Value = 2; MarkerColor = "Blue   "; output;
  72. Value = 3; MarkerColor = "Purple "; output;
  73. Value = 4; MarkerColor = "Gold   "; output;
  74. Value = 5; MarkerColor = "Chartreuse"; output;
  75. run;

  76. *ods graphics / width=400px height=800px;
  77. proc sgplot data=All noautolegend dattrmap=Attrs;
  78. title "SAS Christmas Tree";
  79. scatter x=x y=y / markerattrs=(size=1 color=ForestGreen);
  80. scatter x=x1 y=y1 / transparency=0.33 attrid=Ornaments
  81.         markerattrs=(size=8 symbol=CircleFilled) group=group;
  82. scatter x=x2 y=y2 / markerattrs=(color=Gold size=15 symbol=StarFilled);
  83. yaxis display=none;
  84. xaxis display=none;
  85. run;
复制代码

二维码

扫码加我 拉你入群

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

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

关键词:merry err mas 圣诞树 Transparency 圣诞 mas display create close

SAS资源
1. SAS 微信:StatsThinking
2. SAS QQ群:348941365
沙发
317792209 在职认证  学生认证  发表于 2012-12-15 09:53:04 |只看作者 |坛友微信交流群
厉害啊
按时毕业,按时睡觉。多发论文,多赚点钱。

使用道具

藤椅
melody21 发表于 2012-12-15 10:44:38 |只看作者 |坛友微信交流群
run了一下,出不来。。
膜拜~~

使用道具

板凳
bobguy 发表于 2012-12-15 23:14:56 |只看作者 |坛友微信交流群
Rick Wicklin is really a SAS大牛. If you want to became a good SAS programmer/stat analyst, you should read his blog and take his advice seriously.

使用道具

报纸
webgu 发表于 2012-12-16 08:55:53 |只看作者 |坛友微信交流群
bobguy 发表于 2012-12-15 23:14
Rick Wicklin is really a SAS大牛. If you want to became a good SAS programmer/stat analyst, you shou ...
Thanks for your advice. I 'm trying my best.
SAS资源
1. SAS 微信:StatsThinking
2. SAS QQ群:348941365

使用道具

地板
leilei1573 发表于 2012-12-17 00:26:19 |只看作者 |坛友微信交流群
用这个程序run了一下,没出来,呵呵呵。

使用道具

7
webgu 发表于 2012-12-17 12:23:05 |只看作者 |坛友微信交流群
leilei1573 发表于 2012-12-17 00:26
用这个程序run了一下,没出来,呵呵呵。
应该是可以的。你再试试。
SAS资源
1. SAS 微信:StatsThinking
2. SAS QQ群:348941365

使用道具

8
flutter88 发表于 2012-12-17 16:24:40 |只看作者 |坛友微信交流群
好厉害!!!!!!!

使用道具

9
aucklandsvivian 发表于 2012-12-17 19:29:21 |只看作者 |坛友微信交流群
汗了。。。好牛哇。。。。。。。

使用道具

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

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

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

GMT+8, 2024-6-6 17:35