编程|SAS-时药曲线的绘制
作者看了一些生物等效性的资料,于是还在努力学习的过程中打算分享一段关于绘制时药曲线的程序。内容虽然比较单一,但是涉及到的SAS画图语句以及一些程序处理的细节也是值得一看的。
时药曲线
ods rtf file="D:\日常练习\方差分析\PK\data\test.rtf";ods graphics / width=550px height=400px border=off;proc sgplot data=have noborder ; styleattrs datacontrastcolors=( blue red) datalinepatterns=(solid shortdash) datasymbols=(circle triangle); scatter x=PKTPT y=MEAN / group=GROUP yErrorUpper =upperstd yErrorlower=lowerstd ; series x=PKTPT y=MEAN/ group=GROUP name='L2' lineattrs=(thickness=2) markers ; keylegend 'L2' / location=inside position=topright noborder ACROSS=1 ; xaxis label="时间(h)" values=(0 to 80 by 10) ; yaxis label="血药浓度(ng/mL)" values=(0 to 500 by 50 );run;ods rtf close;
ods rtf file="D:\日常练习\方差分析\PK\data\test.rtf";ods graphics / width=550px height=400px border=off;proc template; define statgraph drwaaa; begingraph/backgroundcolor=white border=false ; dynamic Yvar1 ;*实现 散点形状、线条类型、颜色; ; discreteattrmap name="temp1" / ignorecase=true; value "R" /markerattrs=GraphData1(color=blue symbol=circle) lineattrs=GraphData1(color=blue pattern=solid); value "T" /markerattrs=GraphData1(color=red symbol=triangledown) lineattrs=GraphData1(color=red pattern=shortdash); enddiscreteattrmap; discreteattrvar attrvar=markers var=group attrmap="temp1"; layout lattice / border=false ; layout OVERLAY/CYCLEATTRS=TRUE Xaxisopts=(gridDisplay=off LABEL="时间(h)" LABELATTRS=( size=7pt)/*坐标轴标签属性修改*/ TICKVALUEATTRS=( size=7pt)/*坐标轴值属性修改*/ linearopts=( TICKVALUELIST=(0 10 20 30 40 50 60 70 80 ) ) ) Yaxisopts=(gridDisplay=off LABEL="血药浓度(ng/mL)" LABELATTRS=(size=7pt)/*坐标轴标签属性修改*/ TICKVALUEATTRS=( size=7pt)/*坐标轴值属性修改*/ linearopts=( TICKVALUELIST=(0 50 100 150 200 250 300 350 400 450 500 ) ) ); seriesplot x=PKTPT y=Yvar1 / group=markers name="series" lineattrs=(thickness=2) display=(markers) ; Scatterplot X=PKTPT Y=Yvar1/ yerrorlower=lowerstd yerrorupper=upperstd GROUP=markers ; discretelegend "series" / location=inside autoalign=(topright topleft) opaque=true border=false across=1; endlayout; endlayout; Endgraph; end;run;proc sgrender data=have template=drwaaa;dynamic Yvar1="MEAN";run;ods rtf close;
ods graphics / width=&sum_width. cm height=&sum_height. cm border=off;%if &_out_loop. ne 0 %then %do; data _null_; set _codds1; call symput('_lista'||compress(put(_n_,best.)),strip(finala)); call symput('_listb'||compress(put(_n_,best.)),strip(finalb)); run; proc template; define statgraph drwa; begingraph/backgroundcolor=white border=false ; dynamic %do i=1 %to &page_num_gif. ;%sysfunc(compress(YVAR&i.)) %end;%do i=1 %to &page_num_gif. ;%sysfunc(compress(Ytitle&i.)) %end;; ; *循环实现 散点形状、线条类型、颜色; ; discreteattrmap name="temp1" / ignorecase=true; %do i=1 %to &_tmp.; value "&&_gp&i." /markerattrs=GraphData1(color=&&_color&i. symbol=&&_marktype&i.) lineattrs=GraphData1(color=&&_color&i. pattern=&&_lintype&i.); %end; enddiscreteattrmap; discreteattrvar attrvar=markers var=&group. attrmap="temp1"; layout lattice /columns=&colunms. rows=&rows. columngutter=1cm rowgutter=1cm border=false ; %do i=1 %to &page_num_gif.; layout OVERLAY/CYCLEATTRS=TRUE Xaxisopts=(gridDisplay=off LABEL="时间(h)" LABELATTRS=( size=7pt)/*坐标轴标签属性修改*/ TICKVALUEATTRS=( size=7pt)/*坐标轴值属性修改*/ %if %length(&xvalue.) %then %do;linearopts=( TICKVALUELIST=(&xvalue. ) ) %end; ) Yaxisopts=(gridDisplay=off LABEL="血药浓度(ng/mL)" LABELATTRS=(size=7pt)/*坐标轴标签属性修改*/ TICKVALUEATTRS=( size=7pt)/*坐标轴值属性修改*/ %if %length(&yvalue.) %then %do; linearopts=( TICKVALUELIST=(&Yvalue. ) ) %end; ); seriesplot x=&PKTPT y=YVAR&i. / group=markers name="series&i." lineattrs=(thickness=2) display=(markers) ; discretelegend "series&i." / valueattrs=(family="arial" size=7pt) title=Ytitle&i. titleattrs=GraphValueText(color=black size=8pt ) location=inside autoalign=(topright topleft) opaque=true border=false across=1; endlayout; %end; endlayout; Endgraph; end; run;%end;%if &_out_mod. ne 0 %then %do; data _null_; set _codds2; call symput('_mlista'||compress(put(_n_,best.)),strip(finala)); call symput('_mlistb'||compress(put(_n_,best.)),strip(finalb)); run; proc template; define statgraph drwb; begingraph/backgroundcolor=white border=false ; dynamic %do i=1 %to &_out_mod. ;%sysfunc(compress(YVAR&i.)) %end;%do i=1 %to &_out_mod. ;%sysfunc(compress(Ytitle&i.)) %end;; *循环实现 散点形状、线条类型、颜色; ; discreteattrmap name="temp1" / ignorecase=true; %do i=1 %to &_tmp.; value "&&_gp&i." /markerattrs=GraphData1(color=&&_color&i. symbol=&&_marktype&i.) lineattrs=GraphData1(color=&&_color&i. pattern=&&_lintype&i.); %end; enddiscreteattrmap; discreteattrvar attrvar=markers var=&group. attrmap="temp1"; layout lattice /columns=&colunms. rows=&rows. columngutter=1cm rowgutter=1cm border=false ; %do i=1 %to &_out_mod.; layout OVERLAY/CYCLEATTRS=TRUE Xaxisopts=(gridDisplay=off LABEL="时间(h)" LABELATTRS=( size=7pt)/*坐标轴标签属性修改*/ TICKVALUEATTRS=( size=7pt)/*坐标轴值属性修改*/ %if %length(&xvalue.) %then %do;linearopts=( TICKVALUELIST=(&xvalue. ) ) %end; ) Yaxisopts=(gridDisplay=off LABEL="血药浓度(ng/mL)" LABELATTRS=(size=7pt)/*坐标轴标签属性修改*/ TICKVALUEATTRS=( size=7pt)/*坐标轴值属性修改*/ %if %length(&yvalue.) %then %do; linearopts=( TICKVALUELIST=(&Yvalue. ) ) %end; ); seriesplot x=&PKTPT y=YVAR&i. / group=markers name="series&i." lineattrs=(thickness=2) display=(markers) ; discretelegend "series&i." / valueattrs=(family="arial" size=7pt) title=Ytitle&i. titleattrs=GraphValueText(color=black size=8pt ) location=inside autoalign=(topright topleft) opaque=true border=false across=1; endlayout; %end; endlayout; Endgraph; end; run;%end;ods rtf file="&outpath.";%if &_out_loop. ne 0 %then %do; %do i=1 %to &_out_loop.; proc sgrender data=have3 template=drwa; dynamic &&_lista&i.; dynamic &&_listb&i.; run; %end;%end;%if &_out_mod. ne 0 %then %do;proc sgrender data=have3 template=drwb;dynamic &_mlista1;dynamic &_mlistb1;run;%end;ods rtf close;proc delete data=have3 have2 _codds _codds1 _codds2;quit;%mend;
免责声明:本文转载自SAS程序分享号号号,作者:setup,版权归原作者所有,仅供个人学习交流使用。转载请注明出处。如因作品内容、版权等存在问题,请于本文刊发30日内联系法迈医讯进行删除或洽谈版权使用事宜。
不感兴趣
看过了
取消
不感兴趣
看过了
取消
精彩评论
相关阅读