楼主: zwnSAS121
2054 0

[程序分享] 解决实际问题之SAS画分组柱状-折线图 [推广有奖]

  • 6关注
  • 2粉丝

博士生

19%

还不是VIP/贵宾

-

威望
0
论坛币
294 个
通用积分
2.0010
学术水平
13 点
热心指数
16 点
信用等级
13 点
经验
2473 点
帖子
112
精华
0
在线时间
330 小时
注册时间
2015-12-18
最后登录
2020-8-29

楼主
zwnSAS121 发表于 2017-3-3 15:44:20 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
  1. /*解决实际问题之SAS画分组柱状-折线图*/
  2. data sbp;
  3. input id age sbp hy;
  4. cards;
  5. 1        4        70        0
  6. 2        4        75        1
  7. 3        4        73        1
  8. 4        5        76        1
  9. 5        5        80        1
  10. 6        5        78        1
  11. 7        5        58        0
  12. 8        6        80        1
  13. 9        6        90        1
  14. 10        7        76        0
  15. 11        7        90        1
  16. 12        7        98        1
  17. 13        8        89        0
  18. ;

  19. proc sql noprint;
  20. create table test1 as
  21. select mean(sbp) as sbp_mean,
  22. age
  23. from sbp
  24. group by age
  25. order by age
  26. ;
  27. quit;

  28. proc sql noprint;
  29. create table test2 as
  30. select count(hy) as hy1,
  31. age
  32. from sbp
  33. where hy=1
  34. group by age;
  35. quit;

  36. proc sql noprint;
  37. create table test3 as
  38. select count(hy) as hy0,
  39. age,
  40. from sbp
  41. where hy=0
  42. group by age;
  43. quit;

  44. proc sort data=test2;by age;run;
  45. proc sort data=test3;by age;run;
  46. data test4;
  47. merge test2 test3;
  48. by age;
  49. if hy0=. then hy0=0;
  50. else if hy1=. then hy1=0;
  51. percent=hy1/(hy0+hy1);
  52. format percent percent8.2;
  53. run;

  54. /*SAS 9.4 M2*/
  55. proc sgplot data=test1 noautolegend;
  56.   series x=age y=sbp_mean /
  57.          lineattrs=(thickness=2 color="#00b8e5") dataskin=pressed
  58.          markers markerattrs=(symbol=trianglefilled color=red size=10);
  59.                  yaxis ranges=(0-90) label="sbp平均水平";
  60.                  xaxis label="年龄";
  61. run;

  62. /*SAS 9.4 M3*/
  63. proc sgplot data=test1 noautolegend;
  64. vbarbasic age / response=sbp_mean dataskin=gloss fillattrs=(color="#00bc57")
  65.          baselineattrs=(thickness=0) barwidth=0.7;
  66.   series x=age y=sbp_mean / arrowheadpos=end arrowheadshape=filled
  67.          lineattrs=(thickness=5 color="#00b8e5") dataskin=pressed
  68.                  markers markerattrs=(symbol=circlefilled color=red size=15);
  69.                  yaxis label="sbp平均水平";
  70.                  xaxis label="年龄";
  71. run;

  72. /*SAS 9.4 M2*/
  73. proc sgplot data=test4 noautolegend;
  74.   series x=age y=percent /
  75.          lineattrs=(thickness=5 color="#00bc57") dataskin=pressed
  76.                  markers markerattrs=(symbol=circlefilled color=red size=15);
  77.                  yaxis label="hy=1的百分比";
  78.                  xaxis label="年龄";
  79. run;

  80. /*SAS 9.4 M3*/
  81. proc sgplot data=test4 noautolegend;
  82. vbarbasic age / response=percent dataskin=gloss fillattrs=(color="#00bc57")
  83.          baselineattrs=(thickness=0) barwidth=0.7;
  84.   series x=age y=percent / arrowheadpos=end arrowheadshape=filled
  85.          lineattrs=(thickness=5 color="#00b8e5") dataskin=pressed
  86.                  markers markerattrs=(symbol=circlefilled color=red size=10);
  87.                  yaxis label="hy=1的百分比";
  88.                  xaxis label="年龄";
  89. run;
复制代码


二维码

扫码加我 拉你入群

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

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

关键词:实际问题 折线图 proc sql Baseline response

已有 1 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
yongyitian + 5 + 1 + 1 + 1 鼓励积极发帖讨论

总评分: 论坛币 + 5  学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

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

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