SAS (統(tǒng)計(jì)分析軟件)課件:第17章 數(shù)據(jù)展現(xiàn)_第1頁
SAS (統(tǒng)計(jì)分析軟件)課件:第17章 數(shù)據(jù)展現(xiàn)_第2頁
SAS (統(tǒng)計(jì)分析軟件)課件:第17章 數(shù)據(jù)展現(xiàn)_第3頁
SAS (統(tǒng)計(jì)分析軟件)課件:第17章 數(shù)據(jù)展現(xiàn)_第4頁
SAS (統(tǒng)計(jì)分析軟件)課件:第17章 數(shù)據(jù)展現(xiàn)_第5頁
已閱讀5頁,還剩52頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、第17章 數(shù)據(jù)展現(xiàn)數(shù)據(jù)展現(xiàn)的方式有兩類: 列表方式; 圖形方式。 本章內(nèi)容包括: 利用PRINT過程打印列表展現(xiàn)詳細(xì)數(shù)據(jù)集; 利用TABULATE過程制作匯總報(bào)表展現(xiàn)數(shù)據(jù); 利用GPLOT過程作圖展現(xiàn)數(shù)據(jù)集; 利用GCHART過程輸出高精度圖表。 打印列表過程 利用PRINT過程打印列表展現(xiàn)詳細(xì)數(shù)據(jù)集。 PRINT過程是展現(xiàn)數(shù)據(jù)集內(nèi)容的最簡(jiǎn)單過程。打印列表過程句法PROC PRINT ; BY variable-1 . variable-n ; PAGEBY BY-variable; SUMBY BY-variable; ID variable(s); SUM variable(s); VAR

2、 variable(s); 語句說明: PROC PRINT語句 PROC PRINT ;option(s)選項(xiàng)說明:DATA=規(guī)定要打印列表的數(shù)據(jù)集NOOBS不輸出觀測(cè)數(shù)據(jù)的序號(hào)OBS=為標(biāo)識(shí)觀測(cè)序號(hào)的變量規(guī)定標(biāo)題ROWS=規(guī)定一頁打印的行數(shù)WIDTH=規(guī)定一頁的列寬LABEL輸出時(shí)用變量標(biāo)簽作為列標(biāo)題例17.1 選項(xiàng)說明舉例。DATA=選項(xiàng):proc print data=ResDat.class;proc print ;run; Obs Name Sex Age Height Weight 1 Alice F 13 56.5 84.0 2 Barbara F 13 65.3 98.0 3

3、 Carol F 14 62.8 102.5 4 Jane F 12 59.8 84.5 5 Janet F 15 62.5 112.5 6 Joyce F 11 51.3 50.5 7 Judy F 14 64.3 90.0 8 Louise F 12 56.3 77.0 9 Mary F 15 66.5 112.0 10 Alfred M 14 69.0 112.5 OUTPUT窗口結(jié)果NOOBS選項(xiàng):proc print data=ResDat.class noobs;run;proc print data=ResDat.class split=#;var height;label he

4、ight=This is a Label # for height;run; This is a Label Obs for height 1 56.5 2 65.3 3 62.8 4 59.8 5 62.5 6 51.3 7 64.3 8 56.3 proc print data=ResDat.class (obs=3) noobs;var height weight;title2 身高體重;id name;run; 身高體重 Name Height Weight Alice 56.5 84.0 Barbara 65.3 98.0 Carol 62.8 102.5應(yīng)用舉例 例17.2 選擇打

5、印輸出變量。options nodate pageno=1 linesize=70 pagesize=60;proc print data=ResDat.exprev double;var month state expenses;title Monthly Expenses for Offices in Each State;run;例17.3 定制標(biāo)題內(nèi)容。options nodate pageno=1 linesize=70 pagesize=60;proc print data=ResDat.exprev split=* n obs=Observation*Number*=;var m

6、onth state expenses;label month=Month*= state=State*= expenses=Expenses*=; format expenses comma10.;title Monthly Expenses for Offices in Each State;run;例17.4 分組創(chuàng)建輸出報(bào)告。options pagesize=60 pageno=1 nodate linesize=70;proc sort data=ResDat.exprev;by region state month;run;proc print data=ResDat.exprev

7、 n=Number of observations for the state: noobs label;var month expenses revenues;by region state;pageby region;label region=Sales Region;format revenues expenses comma10.;title Sales Figures Grouped by Region and State;run;例17.5 對(duì)BY組中的數(shù)值變量求和。options nodate pageno=1 linesize=70 pagesize=60 nobyline;p

8、roc sort data=ResDat.exprev;by region;run;proc print data=ResDat.exprev noobs n=Number of observations for the state: ;sum expenses revenues;by region;format revenues expenses comma10.;title Revenue and Expense Totals for the #byval(region) Region;run;options byline;例17.9 用BY組和ID變量定制輸出。options nodat

9、e pageno=1 linesize=64 pagesize=60;proc sort data=ResDat.empdata out=tempemp;by jobcode gender;run;proc print data=tempemp split=*;id jobcode;by jobcode;var gender salary;sum salary;label jobcode=Job Code*= gender=Gender*= salary=Annual Salary*=;format salary dollar11.2;where jobcode contains FA or

10、jobcode contains ME;title Expenses Incurred for;title2 Salaries for Flight Attendants and Mechanics;run;制表過程 利用TABULATE過程可以制作匯總報(bào)表展現(xiàn)數(shù)據(jù)。 制表過程既有頻數(shù)統(tǒng)計(jì)和常用描述統(tǒng)計(jì)的計(jì)算功能,又有很強(qiáng)的用表格展現(xiàn)數(shù)據(jù)的功能。制表過程句法 PROC TABULATE ; BY variable-1 . variable-n ; CLASS variable(s) ; CLASSLEV variable(s) / style =style-element-name | ; F

11、REQ variable; KEYLABEL keyword-1=description-1 ; KEYWORD keyword(s) / style =style-element-name | ; TABLE row-expression, column-expression ; VAR analysis-variable(s); WEIGHT variable;語句說明: TABLE語句 TABLE row-expression, column-expression ; 和PRINT過程不同,TABULATE過程沒有一個(gè)缺省的報(bào)表格式,所有由TABULATE過程輸出報(bào)表時(shí),必須先對(duì)報(bào)表的進(jìn)

12、行布局設(shè)計(jì)。報(bào)表布局設(shè)計(jì)要用到TABLE語句。 TABLE語句的選項(xiàng)非常復(fù)雜,使用時(shí)可查看SAS系統(tǒng)的幫助。這里我們通過例子來說明一些選項(xiàng)的使用方法 。應(yīng)用舉例例17.11創(chuàng)建二維報(bào)表。proc format;value regfmt 1=Northeast 2=South 3=Midwest 4=West;value divfmt 1=New England 2=Middle Atlantic 3=Mountain 4=Pacific;value usetype 1=Residential Customers 2=Business Customers;run;options nodate p

13、ageno=1 linesize=80 pagesize=60;proc tabulate data=ResDat.energy format=dollar12.;class region division type;var expenditures;table region*division, type*expenditures / rts=25;format region regfmt. division divfmt. type usetype.;title Energy Expenditures for Each Region;title2 (millions of dollars);

14、run;例17.12 規(guī)定CLASS變量組合出現(xiàn)在報(bào)表中。options nodate pageno=1 linesize=80 pagesize=60;proc tabulate data=ResDat.energy format=dollar12. classdata=ResDat.classes exclusive;class region division type;var expenditures;table region*division, type*expenditures / rts=25;format region regfmt. division divfmt. type

15、usetype.;title Energy Expenditures for Each Region;title2 (millions of dollars);run; 例17.14 定制行列標(biāo)題。options nodate pageno=1 linesize=80 pagesize=60;proc tabulate data=ResDat.energy format=dollar12.;class region division type;var expenditures;table region*division, type=Customer Base*expenditures= *su

16、m= / rts=25;format region regfmt. division divfmt. type usetype.;title Energy Expenditures for Each Region;title2 (millions of dollars);run;例17.18 創(chuàng)建多頁報(bào)表。options nodate pageno=1 linesize=80 pagesize=60;proc tabulate data=ResDat.energy format=dollar12.;class region division type;var expenditures;tabl

17、e region=Region: all=All Regions, division all=All Divisions, type=Customer Base*expenditures= *sum= / rts=25 box=_page_ condense indent=1;format region regfmt. division divfmt. type usetype.;title Energy Expenditures for Each Region and All Regions;title2 (millions of dollars);run;例17.21 計(jì)算百分比統(tǒng)計(jì)量。o

18、ptions nodate pageno=1 linesize=105 pagesize=60; proc format;picture pctfmt low-high=009 %;run;title Fundraiser Sales;proc tabulate data=ResDat. Fundrais format=7.;class team classrm;var sales;table (team all)*sales= , classrm=Classroom*(sum colpctsum*f=pctfmt9. rowpctsum*f=pctfmt9. reppctsum*f=pctf

19、mt9.) all /rts=20 row=float;run;例17.23 輸出ods html body=x:ResDathtml.htm;proc tabulate data=ResDat.energy style=font_weight=bold;class region division type / style=just=center;classlev region division type / style=just=left;var expenditures / style=font_size=3;keyword all sum / style=font_width=wide;

20、keylabel all=Total;table (region all)*(division all*style=background=yellow), (type all)*(expenditures*f=dollar10.) / style=background=red misstext=label=Missing style=font_weight=light box=label=Region by Division by Type style=font_style=italic;format region regfmt. division divfmt. type usetype.;

21、title Energy Expenditures;title2 (millions of dollars);run;ods html close;run;作圖過程 圖形是展現(xiàn)數(shù)據(jù)的重要方法,圖形的形象直觀是數(shù)據(jù)報(bào)表無法替代的。SAS/GRAPH軟件具有強(qiáng)大的作圖功能。SAS/GRAPH軟件可以展現(xiàn)圖形有: 散點(diǎn)圖及連線圖(PLOTS); 圖表(CHARTS); 地圖(MAPS); 三維圖(3D GRAPHICS); 幻燈片(TEXT SLIDES)等。本章介紹制作圖形的兩個(gè)基本過程:作圖過程(GPLOT過程)和圖表過程(GCHART過程)。作圖過程GPLOT輸出高精度散點(diǎn)圖及連線圖。作圖過程

22、句法 PROC GPLOT GOUT=output-catalog ; BUBBLE plot-request(s) ; BUBBLE2 plot-request(s) ; PLOT plot-request(s) ; PLOT2 plot-request(s) ; PLOT語句 PLOT語句規(guī)定橫軸變量 (行在前面)和豎軸變量 (列在后面)。 選項(xiàng)說明: SYMBOL語句 SYMBOL語句規(guī)定圖中線和符號(hào)的特征。選項(xiàng)說明:AXIS語句 AXIS語句規(guī)定圖形的軸的表現(xiàn)形式。選項(xiàng)說明: 應(yīng)用舉例 例17.24 創(chuàng)建簡(jiǎn)單泡沫(Bubble)圖。goptions reset=global gunit

23、=pct border cback=white colors=(black blue green red) ftitle=swissb ftext=swiss htitle=6 htext=4;title1 Member Profile;title2 Salaries and Number of Member Engineers;footnote h=3 j=r GR21N01 ;axis1 offset=(5,5);proc gplot data=ResD;format dollars dollar9.;bubble dollars*eng=num / haxis=axis1;

24、run;quit;例17.25 規(guī)定泡沫的大小和標(biāo)簽。goptions reset=global gunit=pct border cback=white colors=(black blue green red) ftitle=swissb ftext=swiss htitle=6 htext=4;title1 Member Profile;title2 h=4 Salaries and Number of Member Engineers;footnote1 h=3 j=r GR21N02 ;axis1 label=noneoffset=(5,5)width=3value=(height=

25、4);axis2 order=(0 to 40000 by 10000) label=none major=(height=1.5) minor=(height=1) width=3 value=(height=4);/*接上頁*/ proc gplot data=ResD; format dollars dollar9. num comma7.0; bubble dollars*eng=num / haxis=axis1 vaxis=axis2 vminor=1 bcolor=red blabel bfont=swissi bsize=12 caxis=blue;run;qui

26、t;例17.26 右側(cè)加一垂直軸。goptions reset=global gunit=pct border cback=white colors=(black blue green red) ftitle=swissb ftext=swiss htitle=6 htext=3;data ResD2; set ResD; yen=dollars*125;run;title1 Member Profile;title2 h=4 Salaries and Number of Member Engineers;footnote j=r GR21N03 ;axis1 of

27、fset=(5,5) label=none width=3 value=(h=4);/*接上頁*/proc gplot data=ResD2;format dollars dollar7. num yen comma9.0;bubble dollars*eng=num / haxis=axis1 vaxis=10000 to 40000 by 10000 hminor=0 vminor=1 blabel bfont=swissi bcolor=red bsize=12 caxis=blue;bubble2 yen*eng=num / vaxis=1250000 to 500000

28、0 by 1250000 vminor=1 bcolor=red bsize=12 caxis=blue;run;quit; 例17.28 疊加圖形。goptions reset=global gunit=pct border cback=white colors=(black blue green red) ftitle=swissb ftext=swiss htitle=6 htext=4; title1 Dow Jones Yearly Highs and Lows;footnote1 h=3 j=l Source: 1997 World Almanac j=r GR21N06 ;sym

29、bol1 color=red interpol=join value=dot height=3;symbol2 font=marker value=C color=blue interpol=join height=2;/*接上頁*/axis1 order=(1955 to 1995 by 5) offset=(2,2) label=none major=(height=2) minor=(height=1) width=3;axis2 order=(0 to 6000 by 1000) offset=(0,0) label=none major=(height=2) minor=(heigh

30、t=1) width=3;legend1 label=none shape=symbol(4,2) position=(top center inside) mode=share;proc gplot data=ResDat.djia;plot high*year low*year / overlay legend=legend1 vref=1000 to 5000 by 1000 lvref=2 haxis=axis1 hminor=4 vaxis=axis2 vminor=1;run;quit; 圖表過程 圖表過程GCHART輸出高精度圖表。使用GCHART過程可以制作二維或三維的柱狀圖和

31、餅圖。 圖表過程句法PROC GCHART GOUT=output-catalog BLOCK chart-variable(s) HBAR | HBAR3D | VBAR | VBAR3Dchart-variable(s) PIE | PIE3D | DONUT chart-variable(s) STAR chart-variable(s) 過程GCHART表現(xiàn)的是數(shù)據(jù)的匯總信息,即在某種分類下分析變量的某些統(tǒng)計(jì)量。 GCHART過程的圖形類別及相關(guān)統(tǒng)計(jì)量數(shù)值的表示方法 分類變量及類別 分類變量(chart-variable)也稱為作圖變量,GCHART過程根據(jù)它的值將數(shù)據(jù)分成若干類,然后

32、分別對(duì)柱或角來表示分析變量在某一類中的匯總結(jié)果。 分類變量確定類別的方法GCHART過程還提供不同的選項(xiàng)允許按不同的要求進(jìn)行分類。GCHART過程不提供分析變量時(shí),作圖時(shí)使用的缺省統(tǒng)計(jì)量是頻數(shù),指明分析變量時(shí)使用的缺省統(tǒng)計(jì)量是總和。為了控制柱(餅的角)的排列順序和用數(shù)值變量分類時(shí)類的個(gè)數(shù)。可以使用GCHART過程與分類變量有關(guān)的選項(xiàng)。與分類變量有關(guān)的選項(xiàng)說明: 例17.33 分類變量選項(xiàng)舉例。vbar sales / levels=10;vbar sales / 1000 to10000 by 1000;vbar year / discrete;hbar city / mindpoint=BJ

33、 SH GZ;hbar city / ascending;選擇分析變量和統(tǒng)計(jì)量 沒有選擇分析變量時(shí),缺省使用每個(gè)類的觀測(cè)頻數(shù)為輸出統(tǒng)計(jì)量。選擇分析變量和統(tǒng)計(jì)量的選項(xiàng)有: SUMVAR=規(guī)定分析變量; TYPE=FREQ|CFREQ|PERCENT|CPERCENT|MEAN|SUM分別設(shè)定統(tǒng)計(jì)量為頻數(shù)、累積頻數(shù)、百分比、累積百分比、均值或總和。沒有規(guī)定分析變量時(shí),缺省統(tǒng)計(jì)量為FREQ,規(guī)定分析變量時(shí),缺省統(tǒng)計(jì)量為SUM。使用統(tǒng)計(jì)量MEAN和SUM時(shí)必須規(guī)定分析變量。 例17.34 規(guī)定分析變量和統(tǒng)計(jì)量。hbar city / sumvar=sales type=mean;應(yīng)用舉例 例17.35

34、 總和統(tǒng)計(jì)量柱形圖。goptions reset=global gunit=pct border cback=white ctext=black colors=(blue green red) ftext=swiss ftitle=swissb htitle=6 htext=3.5;title Total Sales;footnote j=r GR13N01;proc gchart data=ResDat.totals;format sales dollar8.;block site / sumvar=sales;run;quit;例17.36 分組柱形圖。goptions reset=glo

35、bal gunit=pct border cback=white colors=(blue green red) ctext=blackftitle=swissb ftext=swiss htitle=4 htext=3;title Average Sales by Department;footnote j=r GR13N02 ;legend1 cborder=black label=(Quarter:) position=(middle left outside) mode=protect across=1; /*接上頁*/proc gchart data=ResDat.totals;format quarter roman.;format sales dollar8.;label site=00 x dept=00 x;block site / sumvar=sales type=mean midp

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論