直接举个列子
想要生成一个受试者分布的流程图,如下:
代码如下:
proc template;
define style trial/store=WORK.TEMPLAT;
parent=Styles.RTF;
class Body/
leftmargin=1.5cm
rightmargin=1.5cm
topmargin=1cm
bottommargin=1cm
;
%if %trim(&TsLanguage)=en %then %do;
class Fonts/
'TitleFont'=("Courier New", 10pt, bold)
'FootnoteFont'=("Courier New", 9pt)
'headingFont'=("Courier New", 10pt, bold)
'docFont'=("Courier New", 10pt)
;
%end;
%else %if %trim(&TsLanguage)=cn %then %do;
class Fonts/
'TitleFont'=("SimSun", 10pt, bold)
'FootnoteFont'=("SimSun", 9pt)
'headingFont'=("SimSun", 10pt, bold)
'docFont'=("SimSun", 10pt)
;
%end;
/*-------------------------------*/
/*Set The Format of all of Title*/
/*-------------------------------*/
class SystemTitle/
textalign = left
;
/*---------------------------*/
/*Set The Format of Title 1-2*/
/*---------------------------*/
/* class SystemTitle/*/
/* textalign = left*/
/* fontsize=10pt*/
/* ;*/
/*---------------------------*/
/*Set The Format of Title 3-5*/
/*---------------------------*/
/* class SystemTitle3/*/
/* textalign = center*/
/* fontsize=12pt*/
/* ;*/
/*---------------------------*/
/*Set The Format of Title6-N*/
/*---------------------------*/
/* class SystemTitle6/*/
/* textalign = left*/
/* fontsize=10pt*/
/* ;*/
class Table/
background=white
frame=hsides
rules=groups
cellpadding=1pt
cellspacing=0pt
textalign=left
width=100%
protectspecialchars=off
;
class HeadersAndFooters/
backgroundcolor=white
textalign=left
asis=on
protectspecialchars=off
;
class Data/
font=Fonts('docFont')
asis=on
protectspecialchars=off
;
/*Set The Format of Footnotes*/
class SystemFooter/
textalign = left
font=Fonts('FootnoteFont')
;
end;
run;
%annomac;
%macro add_element(x=,y=,width=,height=,text=);
%rect(&x,&y,&x+&width,&y+&height,black,1,1);
%let i=1;
%do %until (%qscan(&text,&i,'|')=);
%label(&x+1,&y+&height-2.5*&i,"%qscan(&text,&i,'|')",BLACK,0,0,2.5,SimSun,6);
%let i=%eval(&i+1);
%end;
%mend add_element;
data final;
length function color style $8. text $60.;
retain xsys '3' ysys '3' hsys '3' when 'a' line 1 function 'label';
%add_element(x=39,y=89,width=14,height=6,text=%str( *** 受试者筛选 ));
%add_element(x=38,y=77,width=16,height=6,text=%str( *** 受试者随机化 ));
%add_element(x=13,y=65,width=22,height=6,text=%str( *** 受试者分配至XXX ));
%add_element(x=56,y=65,width=21,height=6,text=%str( *** 受试者分配至安慰剂 ));
%add_element(x=15,y=54,width=16,height=6,text=%str( *** 服用研究药物 ));
%add_element(x=58,y=54,width=16,height=6,text=%str( *** 服用研究药物 ));
%add_element(x=28,y=28,width=20,height=24,text=%str( *** 治疗结束 | *** 不良事件 | *** 疾病进展 | *** 受试者要求退出 | *** 退出研究 | *** 不良事件 | *** 疾病进展 | *** 受试者要求退出 ));
%add_element(x=71,y=28,width=20,height=24,text=%str( *** 治疗结束 | *** 不良事件 | *** 疾病进展 | *** 受试者要求退出 | *** 退出研究 | *** 不良事件 | *** 疾病进展 | *** 受试者要求退出 ));
/* %add_element(x=12-10,y=26+15,width=16,height=6,text=%str( 随访期死亡 | N=xxx));*/
/* %add_element(x=72-10,y=26+15,width=16,height=6,text=%str( 随访期死亡 | N=xxx));*/
%add_element(x=30-15-6,y=20,width=28,height=6,text=%str( *** 数据截止时仍在服用研究药物 ));
%add_element(x=54-6+4,y=20,width=28,height=6,text=%str( *** 数据截止时仍在服用研究药物 ));
/*** CONNECTING LINES... ***/
%line(39+7,89,39+7,77+6,BLACK,1,0.1);
%line(46,77,46,77-3,BLACK,1,0.1);
%line(13+11,74,56+11,74,BLACK,1,0.1);
%line(24,74,24,71,BLACK,1,0.1);
%line(67,74,67,71,BLACK,1,0.1);
%line(24,65,24,60,BLACK,1,0.1);
%line(67,65,67,60,BLACK,1,0.1);
%line(24,54,24,26,BLACK,1,0.1);
%line(67,54,67,26,BLACK,1,0.1);
%line(24,40,28,40,BLACK,1,0.1);
%line(67,40,71,40,BLACK,1,0.1);
/* %line(38-10,29+15,28-10,29+15,BLACK,1,0.1);*/
/* %line(62-10,29+15,72-10,29+15,BLACK,1,0.1);*/
run;
quit;
可供参考的链接
一篇文献
https://www.pharmasug.org/proceedings/2011/TT/PharmaSUG-2011-TT08.pdf
SAS help文档
后记
在做另外一张流程图时,有两个需要同时服用的研究药物,我想的流程图是这样但这样不太对,因为两个药是同一批人,所以不开两条线,改成下图更合适