楼主: 匿名
4799 7

[Stata] 在Stata中绘制流程图 [推广有奖]

匿名网友
楼主
匿名网友  发表于 2016-1-21 19:10:29 |坛友微信交流群|倒序 |AI写论文
相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币

  1.         *******************************************************************************
  2.         *******************************************************************************
  3.         *****                                                                     *****
  4.         *****                                                                     *****
  5.         *****                     在Stata中绘制流程图                              *****
  6.         *****                                                                     *****
  7.         *****                                                                     *****
  8.         *****                                                                     *****
  9.         *******************************************************************************
  10.         *******************************************************************************
复制代码
  1. *Definition of boxes and line styles.
  2. local osmall = ", box margin(small) size(vsmall)"
  3. local omain  = ", box margin(small)"
  4. local bc     = ", lwidth(medthick) lcolor(black)"
  5. local bca    = ", lwidth(medthick) lcolor(black) mlcolor(black) mlwidth(medthick) msize(medlarge)"

  6. *Drawing the graph
  7. twoway  /// 1) PCI to draw a box 2) pcarrowi: connecting arrows.
  8.    pci 5.2 0 5.2 6 `bc' || pci 5.2 6 0 6 `bc' || pci 0 6 0 0 `bc' || pci 0 0 5.2 0 `bc' ///
  9. || pci 3 1.5 3 4.5 `bc' || pci 1.9 1.5 1.9 4.5 `bc' || pci 0.9 1.5 0.9 4.5 `bc' ///
  10. || pcarrowi 5 3 3.5 3 `bca' ///
  11. || pcarrowi 4.35 3 4.35 3.35 `bca'  ///
  12. || pcarrowi 3.5 3 3.2 3 `bca'  ///
  13. || pcarrowi 3 3 2.1 3 `bca'  ///
  14. || pcarrowi 1.9 3 1.1 3 `bca'  ///
  15. , /// Text placed using "added text" [ACHTUNG sizes change with content]
  16. text(5 3 "Assessed for eligibility (n= )" `omain') ///
  17. text(4.35 4.5 "Excluded ""(n= )" ///
  18.         "Not meeting inclusion criteria " ///
  19.         "(n= )" ///
  20.         "Declined to participate " ///
  21.         "(n= )" ///
  22.         "Other reasons""(n= )" `osmall') ///
  23. text(3.5 3 "Randomized (n= )" `omain') ///
  24. text(3.1 3 "Allocation"  ) ///
  25. text(2.5 1.5 "ACTIVE" ///
  26.         "Allocated to intervention""(n=)" ///
  27.         "Received allocated intervention ""(n=XXX)" ///
  28.         "Did not receive allocated intervention " ///
  29.         "(give reasons)" ///
  30.         "(n= )" `osmall') ///
  31. text(2.5 4.5 "CONTROL" ///
  32.          "Allocated to intervention" ///
  33.          "(n= )""Received allocated intervention " ///
  34.          "(n= )" ///
  35.          "Did not receive allocated intervention " ///
  36.          "(give reasons)" ///
  37.          "(n= )" `osmall') ///
  38. text(2 3 "Follow-Up" ) ///
  39. text(1.5 1.5 "Lost to follow-up" ///
  40.         "(give reasons)" ///
  41.         "(n= )" ///
  42.         "Discontinued intervention " ///
  43.         "(give reasons)" ///
  44.         "(n= )" `osmall') ///
  45. text(1.5 4.5 "Lost to follow-up" ///
  46.         "(give reasons)" ///
  47.         "(n= )" ///
  48.         "Discontinued intervention " ///
  49.         "(give reasons)" ///
  50.         " (n= )" `osmall') ///
  51. text(1 3 "Analysis" ) ///
  52. text(0.5 1.5 "Analysed" ///
  53.         "(n= )" ///
  54.         "Excluded from analysis" ///
  55.         "(give reasons)" ///
  56.         "(n= )" `osmall') ///
  57. text(0.5 4.5 "Analysed" ///
  58.         "(n= )" ///
  59.         "Excluded from analysis " ///
  60.         "(give reasons)" ///
  61.         "(n= )" `osmall') ///
  62. legend(off) ///
  63. xlabel("") ylabel("") xtitle("") ytitle("") ///
  64. plotregion(lcolor(black)) ///
  65. graphregion(lcolor(black)) xscale(range(0 6)) ///
  66. xsize(2) ysize(3) /// A4 aspect ratio
  67. title("Consort Flowchart") ///
  68. note("{bf: Adapted from:} www.consort-statement.org/consort-statement/flow-diagram" ///
  69. , size(tiny))


  70. //graph export "./flowchart.pdf", as(pdf) replace
复制代码

flowchart.png


flowchart.do.rar (1 KB) 本附件包括:

  • flowchart.do

参考自:https://theesspreckelsen.wordpre ... -consort-flowchart/



2)进一步手动修改的思路

      除了在Stata Graph Editor中可直接编辑外,还可根据需要将图片保存为wmf格式, 插入图片到word编辑基本形状和修正连接线:(格式--->绘图工具---->编辑形状----->更改形状)

     注:上述xsize(2) ysize(3) 2:3 大致为A4纸宽高比

  1. *-以上主要使用text( ,box )/ twoway pci / twoway  pcarrowi

  2. //text(   ,box )用法举例

  3. sysuse auto.dta,clear
  4. scatter price mpg, text(500 30 "Assessed for eligibility (n= )", box fcolor(blue) color(white))

  5. //twoway pci 用于描线段
  6. twoway pci 2 0 2 6 4 0 4 6 0 2 6 2 0 4 6 4  ||    ///
  7.         scatteri 5 1 3 3, msize(ehuge) ms(X)    ||   ///
  8.         scatteri 5 5 1 5, msize(ehuge) ms(Oh) legend(off)
  9. //twoway  pcarrowi 用法举例
  10. twoway pcarrowi 0 0 0 1 (3) "3 o'clock"      ///
  11.         0 0 1 0 (12) "12 o'clock",               ///
  12.         aspect(1) headlabel plotregion(margin(vlarge))
复制代码

Gr.png

Graph.png

Gr2.png

二维码

扫码加我 拉你入群

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

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

关键词:Stata tata 流程图 intervention Eligibility 流程图

已有 1 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
xddlovejiao1314 + 100 + 100 + 5 + 5 + 5 精彩帖子

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

沙发
xddlovejiao1314 学生认证  发表于 2016-1-21 19:31:06 |只看作者 |坛友微信交流群
师弟,有师姐欢迎回来啊。我去和客初说说~

使用道具

藤椅
houyunhuang 发表于 2016-1-21 19:46:23 |只看作者 |坛友微信交流群
已有 1 人评分经验 论坛币 收起 理由
xddlovejiao1314 + 10 + 3 鼓励积极发帖讨论

总评分: 经验 + 10  论坛币 + 3   查看全部评分

使用道具

板凳
晚清 在职认证  发表于 2016-1-21 19:52:39 |只看作者 |坛友微信交流群
pretty good
已有 1 人评分经验 论坛币 收起 理由
xddlovejiao1314 + 10 + 3 鼓励积极发帖讨论

总评分: 经验 + 10  论坛币 + 3   查看全部评分

使用道具

报纸
niuniuyiwan 在职认证  发表于 2016-1-21 20:02:15 |只看作者 |坛友微信交流群
xddlovejiao1314 发表于 2016-1-21 19:31
师弟,有师姐欢迎回来啊。我去和客初说说~
感谢师兄、师姐一番好意,小贴纯属自娱自乐,不必烦扰客版。
已有 1 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
xddlovejiao1314 + 100 + 100 + 5 + 5 + 5 精彩帖子

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

使用道具

地板
niuniuyiwan 在职认证  发表于 2016-1-21 20:15:01 |只看作者 |坛友微信交流群
houyunhuang 发表于 2016-1-21 19:46
已有 1 人评分经验 论坛币 收起 理由
xddlovejiao1314 + 10 + 3 鼓励积极发帖讨论

总评分: 经验 + 10  论坛币 + 3   查看全部评分

使用道具

7
niuniuyiwan 在职认证  发表于 2016-1-21 20:16:05 |只看作者 |坛友微信交流群
晚清 发表于 2016-1-21 19:52
pretty good
Thanks a million!
已有 1 人评分经验 论坛币 收起 理由
xddlovejiao1314 + 10 + 3 鼓励积极发帖讨论

总评分: 经验 + 10  论坛币 + 3   查看全部评分

使用道具

8
houyunhuang 发表于 2016-1-22 11:49:11 |只看作者 |坛友微信交流群
需要这种精神,虽然程序需要简化,像tikz一样直观的语法,然后封装成函数还是不错的
已有 1 人评分经验 论坛币 收起 理由
xddlovejiao1314 + 10 + 3 鼓励积极发帖讨论

总评分: 经验 + 10  论坛币 + 3   查看全部评分

使用道具

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

本版微信群
加好友,备注jltj
拉您入交流群

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

GMT+8, 2024-4-25 21:40