- 阅读权限
- 255
- 威望
- 0 级
- 论坛币
- 4501 个
- 通用积分
- 76.6084
- 学术水平
- 171 点
- 热心指数
- 204 点
- 信用等级
- 133 点
- 经验
- 24581 点
- 帖子
- 584
- 精华
- 1
- 在线时间
- 1862 小时
- 注册时间
- 2008-5-25
- 最后登录
- 2023-9-20
|
- %macro comment(); /*这是一种比较特殊的注释方式*/
- Picture: Data Lattice with Multi-Page Output (using template and sgrender procedure)
- Software: SAS 9.4 TS Level 1M2
- Name: justsoso
- Date: 20180305
- From: Getting Started with the Graph Template Language in SAS:
- Examples, Tips, and Techniques for Creating Custom Graphs
- History: 20180305;
- %mend;
- /*建立数据集GTL_GS_Labs,用于后续画图*/
- /*--Fig 5.2.7 Labs2--*/
- data GTL_GS_Labs2;
- pi=constant('PI');
- do Lab='Lab-1', 'Lab-2', 'Lab-3', 'Lab-4', 'Lab-5', 'Lab-6';
- amp=100*ranuni(4);
- phase=2*pi*ranuni(3);
- do day=1 to 300 by 5;
- Value=amp*(1+0.1*(sin(day*pi/180+phase)+0.2*ranuni(5)));
- output;
- end;
- end;
- run;
- ods _all_ close; /*关闭所有ods destinations,避免不必要的输出,节省计算机资源*/
- /*ods listing gpath='C:\Users\Administrator\Desktop\test20180305' image_dpi=300;*/
- ods listing gpath='C:\Users\Administrator\Desktop\test20180305';
- /*打开ods listing这一destination,指定图片保存路径,★★★★★需提前建立*/
- /*ods graphics on / imagename="picture" outputfmt=pdf;*/
- /*图片名称picture,输出类型pdf*/
- ods graphics off;
- /*Data Lattice with Multi-Page Output*/
- proc template;
- define statgraph Fig_5_2_7;
- begingraph;
- entrytitle 'Lab Value by Day';
- layout datalattice rowvar=lab / headerlabeldisplay=value
- rowaxisopts=(label='Value' griddisplay=on
- tickvalueattrs=(size=7))
- columnaxisopts=(display=(ticks tickvalues)
- tickvalueattrs=(size=7))
- rowdatarange=union rows=3 rowgutter=5;/*rows=3限制单元高度*/
- layout prototype / cycleattrs=true;
- seriesplot x=day y=value /
- lineattrs=graphdata2(thickness=2 pattern=solid);
- endlayout;
- endlayout;
- endgraph;
- end;
- run;
- proc sgrender template=Fig_5_2_7 data=GTL_GS_Labs2;
- run;
- ods _all_ close;
- /*ods html; 最好将ods destination恢复至默认的html*/
复制代码
|
|