Proc gplot.docx
- 文档编号:13764709
- 上传时间:2023-06-17
- 格式:DOCX
- 页数:32
- 大小:490.85KB
Proc gplot.docx
《Proc gplot.docx》由会员分享,可在线阅读,更多相关《Proc gplot.docx(32页珍藏版)》请在冰点文库上搜索。
Procgplot
Proc Gplot:
运用Gplot作图
ProcGplot:
运用Gplot作图
原文地址:
转载请注明出处:
Data如下,为一个时间序列数据。
这个数据是自己编的,只是为了方便测试程序。
datat112;
inputnh_totfg_totyear;
cards;
90901970
1201001971
1701101972
2401201973
3301301974
4401401975
5601501976
6901601977
8501701978
10901801979
12901901980
15902001981
;
run;
1基本用法:
procgplotdata=t112;
plotnh_tot*year;
run;
结果:
2Gplot的一些基本设置
goptionsftext='Arial'htext=2gunit=pct;
symbol1value=dotinterpol=join;
title"NATIONALHEALTHCAREEXPENDITURES:
1970-1982";
footnote"Source:
Health-UnitedStates-2003";
procgplotdata=t112;
plotnh_tot*year;
run;
结果:
3改变标题title和脚注footnote
goptionsftext='Arial'htext=2gunit=pct;
symbol1v=doti=join;
titleheight=4"NATIONALHEALTHCAREEXPENDITURES:
1970-1982";
footnotejustify=right"Source:
Health-UnitedStates-2003";
procgplotdata=t112;
plotnh_tot*year;
run;
4改变横坐标的label设置和纵坐标的显示尺度设置
optionsvalidvarname=upcase;
goptionsftext='Arial'htext=2gunit=pct;
symbol1v=doti=join;
axis1label=(angle=90"AMOUNT(INBILLIONS)")minor=(n=3);
axis2order=(1970to1982by2)minor=(n=4);
titleh=4"NATIONALHEALTHCAREEXPENDITURES:
1970-1982";
footnotej=right"Source:
Health-UnitedStates-2003";
procgplotdata=t112;
plotnh_tot*year/vaxis=axis1haxis=axis2;
formatnh_totcomma.;
run;
5对各文字和横纵坐标加颜色
optionsvalidvarname=upcase;
goptionsftext='Arial'htext=2gunit=pctctext=green;
symbol1v=doti=joinc=blueh=2.5;
axis1label=(angle=90"AMOUNT(INBILLIONS)")minor=(n=3)color=blue;
axis2order=(1970to1982by2)minor=(n=4)color=blue;
title1h=4"NATIONALHEALTHCAREEXPENDITURES:
1970-1982";
footnote1j=right"Source:
Health-UnitedStates-2003";
procgplotdata=t112;
plotnh_tot*year/vaxis=axis1haxis=axis2;
formatnh_totcomma.;
run;
6将所有的文字设置为绿色,而图形和坐标轴设置为蓝色
optionsvalidvarname=upcase;
goptionsftext='Arial'htext=2gunit=pctctext=green;
symbol1v=doti=joinc=blueh=2.5;
axis1label=(angle=90rotate=0"AMOUNT(INBILLIONS)")minor=(n=3);
axis2order=(1970to1982by2)minor=(n=4)offset=(2,2);
titleh=4font='Arial/bo'"NATIONALHEALTHCAREEXPENDITURES:
1970-1982";
footnotej=right"Source:
Health-UnitedStates-2003";
procgplotdata=t112;
plotnh_tot*year/vaxis=axis1haxis=axis2caxis=blue;
formatnh_totcomma.;
run;
7增加别外一个图像,图像叠加:
optionsvalidvarname=upcase;
goptionsftext='Arial'htext=2gunit=pctctext=green;
symbol1v=doti=joinc=blueh=2.5l=1;
symbol2v=doti=joinh=2.5l=3;
axis1label=(angle=90rotate=0"AMOUNT(INBILLIONS)")minor=(n=3);
axis2order=(1970to1982by2)minor=(n=4)offset=(2,2);
titleh=4f='Arial/bo'"NATIONALHEALTHCAREEXPENDITURES:
1970-1982";
footnotej=right"Source:
Health-UnitedStates-2003";
procgplotdata=t112;
plot(nh_totfg_tot)*year/overlayvaxis=axis1haxis=axis2caxis=blue;
formatnh_totcomma.;
run;
8设置曲线的样式:
optionsvalidvarname=upcase;
goptionsftext='Arial'htext=2gunit=pctctext=greencsymbol=blue;
symbol1v=doti=joinc=blueh=2.5l=1;
symbol2v=doti=joinh=2.5l=3;
axis1label=(angle=90rotate=0"AMOUNT(INBILLIONS)")minor=(n=3);
axis2order=(1970to1982by2)minor=(n=4)offset=(2,2);
titleh=4f='Arial/bo'"NATIONALHEALTHCAREEXPENDITURES:
1970-1982";
footnotej=right"Source:
Health-UnitedStates-2003";
procgplotdata=t112;
plot(nh_totfg_tot)*year/overlayvaxis=axis1haxis=axis2caxis=blue;
formatnh_totcomma.;
run;
9增加一个legend,也可以对legend进行调整:
optionsvalidvarname=upcase;
goptionsftext='Arial'htext=2gunit=pctctext=greencsymbol=blue;
symbol1v=doti=joinh=2.5l=1;
symbol2v=doti=joinh=2.5l=3;
axis1label=(angle=90rotate=0"AMOUNT(INBILLIONS)")minor=(n=3);
axis2order=(1970to1982by2)minor=(n=4)offset=(2,2);
titleh=4f='Arial/bo'"NATIONALHEALTHCAREEXPENDITURES:
1970-1982";
footnotej=right"Source:
Health-UnitedStates-2003";
procgplotdata=t112;
plot(nh_totfg_tot)*year/overlayvaxis=axis1haxis=axis2caxis=bluelegend;
formatnh_totcomma.;
run;
10对默认的legend进行修改:
optionsvalidvarname=upcase;
goptionsftext='Arial'htext=2gunit=pctctext=greencsymbol=blue;
symbol1v=doti=joinh=2.5l=1;
symbol2v=doti=joinh=2.5l=3;
axis1label=(angle=90rotate=0"AMOUNT(INBILLIONS)")minor=(n=3);
axis2order=(1970to1982by2)minor=(n=4)offset=(2,2);
legend1label=nonevalue=(j=left"TOTAL"j=left"FEDERALGOVT")
mode=protectposition=(topinsideleft)
cborder=bluecshadow=blue
across=1shape=line(10);
titleh=4f='Arial/bo'"NATIONALHEALTHCAREEXPENDITURES:
1970-1982";
footnotej=right"Source:
Health-UnitedStates-2003";
procgplotdata=t112;
plot(nh_totfg_tot)*year/overlayvaxis=axis1haxis=axis2caxis=bluelegend=legend1;
formatnh_totcomma.;
run;
11对曲线进行标注:
datamy_labels;
retainxsysysys'2'function'label'
position'1'style"'Arial/bo'"
color'blue'cborder'blue';
sett112end=last;
iflastthendo;
text='FEDERALGOVERNMENT';x=year;y=fg_tot;output;
text='TOTAL' ;x=year;y=nh_tot;output;
end;
run;
goptionsftext='Arial'htext=2gunit=pctctext=greencsymbol=blue;
optionsvalidvarname=upcase;
symbol1f=markerv='C'i=joinh=1.25;
symbol2f=markerv='U'i=joinh=1.25;
axis1label=(angle=90rotate=0"AMOUNT(INBILLIONS)")minor=(n=3);
axis2order=(1970to1982by2)minor=(n=4)offset=(2,2);
titleh=4f='Arial/bo'"NATIONALHEALTHCAREEXPENDITURES:
1970-1982";
footnotej=right"Source:
Health-UnitedStates-2003";
procgplotdata=t112;
plot(nh_totfg_tot)*year/overlayvaxis=axis1haxis=axis2caxis=blueannotate=my_labels;
formatnh_totcomma.;
run;
12生成一个GIF图像文件
optionsvalidvarname=upcase;
goptionsdevice=gifgsfname=goutxpixels=1024ypixels=768
ftext='Arial'htext=2gunit=pctctext=greencsymbol=blue;
symbol1f=markerv='C'i=joinh=1.25;
symbol2f=markerv='U'i=joinh=1.25;
axis1label=(angle=90rotate=0"AMOUNT(INBILLIONS)")minor=(n=3);
axis2order=(1970to1982by2)minor=(n=4)offset=(2,2);
legend1label=nonevalue=(j=left"TOTAL"j=left"FEDERALGOVT")
mode=protectposition=(topinsideleft)
cborder=bluecshadow=blue
across=1shape=symbol(6,1.25);
titleh=4f='Arial/bo'"NATIONALHEALTHCAREEXPENDITURES:
1970-2000";
footnotej=right"Source:
Health-UnitedStates-2003";
filenamegout'c:
\healthexp.gif';
procgplotdata=t112;
plot(nh_totfg_tot)*year/overlayvaxis=axis1haxis=axis2caxis=bluelegend=legend1;
formatexpcomma.;
run;
13noframe选项,使得图像能自动调整适合的大小
optionsvalidvarname=upcase;
goptionsftext='Arial'htext=2gunit=pctctext=greencsymbol=blue;
symbol1v=doti=joinh=2.5l=1;
symbol2v=doti=joinh=2.5l=3;
axis1label=(angle=90rotate=0"AMOUNT(INBILLIONS)")minor=(n=3);
axis2order=(1970to1982by5)minor=(n=4)offset=(2,2);
legend1label=nonevalue=(j=left"TOTAL"j=left"FEDERALGOVT")
mode=protectposition=(topinsideleft)
cborder=bluecshadow=blue
across=1shape=line(10);
titleh=4f='Arial/bo'"NATIONALHEALTHCAREEXPENDITURES:
1970-1982";
footnotej=right"Source:
Health-UnitedStates-2003";
procgplotdata=t112;
plot(nh_totfg_tot)*year/overlayvaxis=axis1haxis=axis2caxis=bluelegend=legend1noframe;
formatnh_totcomma.;
run;
SAS/Graph实用基础教程(Gplot、Gchart)
AnIntroductiontotheSimplicityandPowerofSAS/Graph®
SAS/Graph实用基础教程(Gplot、Gchart)
原文地址:
转载请注明出处:
SAS/Graph太强大了,本文主要讲一些常用且功能强大的Graph相关的过程步。
1procgplot的简单例子
procgplotdata=sashelp.shoes;
plot Returns*Sales ;
run;
结果:
2我们也可以只画出符合条件的数据的图形。
procgplotdata=sashelp.shoes;
whereRegionin("UnitedStates","EasternEurope");
plot Returns*Sales ;
run;
结果:
3输出的图像都是默认的黑色的小十字,因此我们不能区分来自不同地区的数据,下面的程序就是为了解决这一问题
procgplotdata=sashelp.shoes;
whereRegionin("UnitedStates","EasternEurope");
plot Returns*Sales=Region;
run;
结果:
这里红色的来自美国,黑色的来自东欧,当然我们也可以自己设定颜色(SAS基本颜色有:
black,red,green,blue,cyan,magenta,grey,pink,orange,brown,andyellow)。
4设定坐标轴和所有文字和颜色
procgplotdata=sashelp.shoes;
whereRegionin("UnitedStates","EasternEurope");
plot Returns*Sales=Region/
caxis=blue
ctext=red
grid;
run;
结果:
5如果要对网格进行更精细地设置,则要用到AUTOHREF和AUTOVREF选项。
AUTOHREF中,LHREF设置水平线的线类型,CHREF设置水平线的线颜色;AUTOVREF中,LVREF设置垂直线的线类型,CVREF设置垂直线的线颜色。
procgplotdata=sashelp.shoes;
whereRegionin("UnitedStates","EasternEurope");
plot Returns*Sales=Region/
autohref lhref=2
chref=lime
autovref lvref=5
cvref=pink
caxis=blue
ctext=red;
run;
结果:
6还可以用VAXIS和HAXIS分别设置纵轴和横轴的刻度。
注意:
如果某个数据超过了你指定的这个刻度,那么这个数据将不会被输出,因此在用这两个选项时要非常小心。
procgplotdata=sashelp.shoes;
whereRegionin("UnitedStates","EasternEurope");
plot Returns*Sales=Region/
vaxis=0to15000by5000
autohref lhref=2
chref=lime
autovref lvref=5
cvref=pink
caxis=blue
ctext=red;
run;
结果:
7下面介绍一些有关Graph相关过程的全局(global)设置
title1c=darkblueh=2.5f=swissb "SAS/Graph"
c=darkredh=3.0f=swissbi"GPLOTExample";
axis1
label=(c=darkorangeh=1.5f=zapfbi
j=r"TotalReturns")
offset=(0.2in)
order=(0to15000by5000)
value=(c=darkorangef=swissl );
axis2
label=(c=darkgreenh=1.5 f=zapfbi)
order=(0to500000by50000)
value=(f=swissl c=darkgreen);
symbol1 c=red h=2 v=#;
symbol2 c=blueh=3 v=diamond;
procgplotdata=sashelp.shoes;
whereRegionin("UnitedStates","EasternEurope");
plotReturns*Sales=Region/
vaxis=axis1 haxis=axis2
autohref lhref=2
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Proc gplot
![提示](https://static.bingdoc.com/images/bang_tan.gif)