- 阅读权限
- 255
- 威望
- 0 级
- 论坛币
- 4511 个
- 通用积分
- 76.8946
- 学术水平
- 171 点
- 热心指数
- 204 点
- 信用等级
- 133 点
- 经验
- 24578 点
- 帖子
- 583
- 精华
- 1
- 在线时间
- 1865 小时
- 注册时间
- 2008-5-25
- 最后登录
- 2025-4-28
|
- %macro comment(); /*这是一种比较特殊的注释方式*/
- Picture: Step Plot (using template and sgrender procedure)
- Software: SAS 9.4 TS Level 1M2
- Name: justsoso
- Date: 20180229
- From: Getting Started with the Graph Template Language in SAS:
- Examples, Tips, and Techniques for Creating Custom Graphs
- History: 20180229;
- %mend;
- /*建立数据集diabetes,用于后续画图*/
- data GTL_GS_stepGroup;
- format Date Date9.;
- do i=0 to 334 by 40;
- date='01jan2009'd+i;
- if mod (i, 30) =0 then freq=1; else freq=0;
- Drug='Drug A'; Val = 16+ 3*sin(i/90+0.5) + 1*sin(3*i/90+0.7);
- upper=val*1.1; lower=val*0.95; output;
- Drug='Drug B'; Val = 11+ 3*sin(i/90+0.5) + 1*cos(3*i/90+0.7);
- upper=val*1.1; lower=val*0.95; output;
- if i > 150 and i < 210 then val=.;
- else Val = 7+ 3*cos(i/90+0.5) + 1*sin(3*i/90+0.7);
- Drug='Drug C'; upper=val*1.1; lower=val*0.95; output;
- end;
- run;
- ods _all_ close; /*关闭所有ods destinations,避免不必要的输出,节省计算机资源*/
- ods listing gpath='C:\Users\Administrator\Desktop\test20180229';
- /*打开ods listing这一destination,指定图片保存路径,★★★★★需提前建立*/
- /*ods graphics on / imagename="picture" outputfmt=pdf; 图片名称picture,输出类型pdf*/
- ods graphics off;
- /*Step Plot*/
- proc template;
- define statgraph Fig_4_2_3;
- begingraph;
- entrytitle 'Response and CL by Time and Treatment';
- layout overlay / xaxisopts=(display=(ticks tickvalues line))
- yaxisopts=(display=(ticks tickvalues line));
- stepplot x=date y=val / group=drug name='s' errorupper=upper
- errorlower=lower lineattrs=(pattern=solid) justify=center
- display=(markers) markerattrs=(symbol=circlefilled) break=true
- curvelabel=drug curvelabelposition=min;
- endlayout;
- endgraph;
- end;
- run;
- proc sgrender data=GTL_GS_stepGroup template=Fig_4_2_3;
- run;
- ods _all_ close;
- /*ods html; 最好将ods destination恢复至默认的html*/
复制代码
|
|