Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Sas code for examples from a first course in statistics

599 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Sas code for examples from a first course in statistics

  1. 1. SAS Code for Examples from a First Course in Statistics If you are running in batch mode, set options at the start of each script so that output will be formatted to fit on a letter size page. options linesize=64 pagesize=55; Do a simple probability calculation and display the result data race; pr = probnorm(-15/sqrt(325)); run; proc print data=race; var pr; run; Do a simple probability calculation and display the result with PROC IML proc iml; FF = FINV(0.05/32,2,29); print FF; quit; Compute, display and plot the ratio of confidence limits for a normal variance (Try writing a simpler version of this using PROC IML.) data chisq; input df; chirat = cinv(.995,df)/cinv(.005,df); datalines; 20 21 22 23 24 25 26 27 28 29 30 ; run; proc print data=chisq; var df chirat; run; proc plot data=chisq;
  2. 2. plot chirat*df; run; Do a 2-Factor ANOVA, data entered in the script data copper; input id warp temp pct; datalines; 1 17 50 40 2 20 50 40 3 16 50 60 4 21 50 60 5 24 50 80 6 22 50 80 9 12 75 40 10 9 75 40 11 18 75 60 12 13 75 60 13 17 75 80 14 12 75 80 25 21 125 40 26 17 125 40 27 23 125 60 28 21 125 60 29 23 125 80 30 22 125 80 ; proc anova data=copper; class temp pct; model warp= temp | pct; run; Do a Simple Linear Regression and plot the result from PROC REG (Plotting from PROC REG does not work in batch mode) data crack; input id age load; datalines; 1 20 11.45 2 20 10.42 3 20 11.14 4 25 10.84 5 25 11.17 6 25 10.54 7 31 9.47 8 31 9.19 9 31 9.54 ; proc reg data=crack; model load = age; plot predicted. * age = 'P' load * age = '*' / overlay;
  3. 3. run; Scatter plot in batch mode data crack; input id age load; datalines; 1 20 11.45 2 20 10.42 3 20 11.14 4 25 10.84 5 25 11.17 6 25 10.54 7 31 9.47 8 31 9.19 9 31 9.54 ; proc plot data=crack; plot load * age = "*"; run; Simple Linear Regression and scatter plot with overlay in batch mode data crack; input id age load; datalines; 1 20 11.45 2 20 10.42 3 20 11.14 4 25 10.84 5 25 11.17 6 25 10.54 7 31 9.47 8 31 9.19 9 31 9.54 ; proc reg data=crack; model load = age / p; output out=crackreg p=pred r=resid; run; proc plot data=crackreg; plot load*age="*" pred*age="+"/ overlay; run; Simple Linear Regression ANOVA with non-linearity test, scatter plot with overlay in batch mode data crack; input id age load agef; datalines; 1 20 11.45 20
  4. 4. 2 20 10.42 20 3 20 11.14 20 4 25 10.84 25 5 25 11.17 25 6 25 10.54 25 7 31 9.47 31 8 31 9.19 31 9 31 9.54 31 ; proc glm data=crack; class agef; model load = age agef / p; output out=crackreg p=pred r=resid; run; proc plot data=crackreg; plot load*age="*" pred*age="+"/ overlay; run; Two-Factor ANOVA, data entered in the script data toxic; input life poison $ treatment $; datalines; 0.31 I A 0.45 I A 0.46 I A 0.43 I A 0.36 II A 0.29 II A 0.40 II A 0.23 II A 0.22 III A 0.21 III A 0.18 III A 0.23 III A 0.82 I B 1.10 I B 0.88 I B 0.72 I B 0.92 II B 0.61 II B 0.49 II B 1.24 II B 0.30 III B 0.37 III B 0.38 III B 0.29 III B 0.43 I C 0.45 I C 0.63 I C 0.76 I C 0.44 II C 0.35 II C 0.31 II C
  5. 5. 0.40 II C 0.23 III C 0.25 III C 0.24 III C 0.22 III C 0.45 I D 0.71 I D 0.66 I D 0.62 I D 0.56 II D 1.02 II D 0.71 II D 0.38 II D 0.30 III D 0.36 III D 0.31 III D 0.33 III D ; run; proc anova data=toxic; class poison treatment; model life = poison treatment poison*treatment; run; Two-Factor ANOVA, data from a comma-delimited text file data toxic; infile "toxic.dat" dlm=","; input life poison $ treatment $; run; proc anova data=toxic; class poison treatment; model life = poison treatment poison*treatment; run; SAS Program *** EXAMPLE 1 ********************; *** Data input, sort and print ***; **********************************; OPTIONS PS=55 LS=77 NOCENTER NODATE NONUMBER; DATA paintdry; INFILE CARDS MISSOVER; INPUT status $ luster hardness timeoday $; CARDS; RUN; Fresh 7 3 Early Dried 8 9 Early Fresh 6 3 Dried 8 7 Late Fresh 5 6 Late ; PROC SORT; BY status luster hardness; RUN; PROC PRINT; RUN;
  6. 6. *** EXAMPLE 2 ******************************; *** Data input and means on two variables ***; *** Output statement ***; ********************************************; OPTIONS PS=51 LS=78 NOCENTER NODATE NONUMBER; data one; infile cards; input x y; cards; run; 1 1 2 3 3 4 4 4 4 5 5 7 7 6 9 7 ; proc means MIN MAX SUM STD USS; var x y; run; Proc print data=one; run; OPTIONS PS=31 LS=80; Proc plot data=one; plot x*y; run; OPTIONS PS=52; *** EXAMPLE 3 ********************; *** Data input, sort and print ***; **********************************; OPTIONS PS=53 LS=79 NOCENTER NODATE NONUMBER; DATA NEW3; INFILE CARDS MISSOVER; INPUT day number type $ model $; CARDS; RUN; 17 9 TRUCKS SEMI 18 8 TRUCKS SEMI 19 2 TRUCKS PICKUP 22 4 TRUCKS SEMI 16 3 CARS COUPE 17 2 CARS COUPE 18 3 CARS SEDAN 19 1 CARS SEDAN 22 5 CARS SEDAN 17 1 VANS 5DOOR 17 4 VANS 4DOOR 19 2 VANS 5DOOR ; PROC SORT DATA=NEW3; BY type model day number; RUN; TITLE1 'My raw data is listed below'; PROC PRINT DATA=NEW3 double; VAR type model day number; RUN; PROC SORT DATA=NEW3; BY TYPE; RUN; TITLE1 'Selected means are provided below'; PROC MEANS DATA=NEW3; BY type; VAR number day; RUN; PROC SORT DATA=NEW3; BY type; RUN; PROC MEANS DATA=NEW3 NOPRINT; BY type; VAR number day; OUTPUT OUT=THREE N=NNo DNo MEAN=NMEAN DMEAN VAR=NVAR DVAR; RUN; TITLE1 'Outputted means are listed below';
  7. 7. PROC PRINT DATA=THREE; VAR TYPE NNo DMEAN NVAR DNo NMEAN DVAR; RUN; *** EXAMPLE 4 ********************************************; *** Reading a file and saving a permanent SAS data set ***; **********************************************************; OPTIONS PS=55 LS=77 NOCENTER NODATE NONUMBER; libname mylib 'A:'; DATA mylib.OLD_DATA; INFILE CARDS MISSOVER; INPUT MONTH DAY YEAR STATION $ SPECIES $ NUMBER; LABEL STATION = 'Sample stations'; LABEL SPECIES = 'Species common name'; LABEL STATION = 'Number caught'; CARDS; RUN; 01 8 97 North Spot 8 01 8 97 North Croaker 3 01 8 97 South Spot 11 03 23 97 North Spot 2 03 23 97 South Spot 5 05 15 97 North Spot 1 05 15 97 North Croaker 3 05 15 97 South Spot 17 05 15 97 South Croaker 2 08 12 97 North Spot 8 08 12 97 North Croaker 3 08 12 97 North RedDrum 1 08 12 97 North Spot 8 08 12 97 North Croaker 9 ; *** EXAMPLE 5 **************************; *** Reading a permanent SAS data set ***; *** Concatenating SAS data sets ***; ****************************************; OPTIONS PS=55 LS=77 NOCENTER NODATE NUMBER PAGENO=1; libname mylib 'A:'; TITLE1 'Example program #5'; DATA NEW_DATA; INFILE CARDS MISSOVER; INPUT MONTH DAY YEAR STATION $ SPECIES $ NUMBER; CARDS; RUN; 01 14 98 North Spot 12 01 14 98 North Croaker 1 01 14 98 North RedDrum 4 01 14 98 South Spot 5 03 6 98 South Spot 3 03 6 98 South Croaker 9 05 26 98 North Spot 11 05 26 98 North Croaker 12 05 26 98 South Spot 4 07 29 98 North Spot 24 07 29 98 North Croaker 16 07 29 98 North Spot 12 07 29 98 North Croaker 7 ; DATA MYLIB.ALL_DATA; SET mylib.old_data NEW_DATA; sasdate = mdy(month, day, year); format sasdate date7.;
  8. 8. RUN; PROC SORT DATA=MYLIB.ALL_DATA; BY SPECIES YEAR MONTH DAY; RUN; PROC PRINT DATA=MYLIB.ALL_DATA; TITLE2 'Raw data listing sorted by species y m d'; VAR SPECIES sasdate STATION NUMBER; RUN; PROC FREQ DATA=MYLIB.ALL_DATA; BY SPECIES; WEIGHT NUMBER; TITLE2 'Species frequency (weighted by number)'; TABLE MONTH*STATION; RUN; PROC FREQ DATA=MYLIB.ALL_DATA; WEIGHT NUMBER; TITLE2 'Species frequency - chi square test'; TABLE MONTH*STATION / chisq cellchi2 norow nocol nopercent; RUN; proc plot data=mylib.all_data; TITLE2 'Scatter plot of number by date'; plot number*sasdate=species; run; proc chart data=mylib.all_data; by species; TITLE2 'Horizontal bar chart'; hbar species / sumvar=number group=station type=sum; run; OPTIONS PS=30 LS=88; proc chart data=mylib.all_data; TITLE2 'Histogram'; vbar species / sumvar=number type=mean; run; SAS Log 1 *** EXAMPLE 1 ********************; 2 *** Data input, sort and print ***; 3 **********************************; 4 OPTIONS PS=55 LS=77 NOCENTER NODATE NONUMBER; 5 DATA paintdry; INFILE CARDS MISSOVER; 6 INPUT status $ luster hardness timeoday $; 7 CARDS; NOTE: The data set WORK.PAINTDRY has 5 observations and 4 variables. NOTE: The DATA statement used 0.05 seconds. 7 RUN; 13 ; 14 PROC SORT; BY status luster hardness; RUN; NOTE: The data set WORK.PAINTDRY has 5 observations and 4 variables. NOTE: The PROCEDURE SORT used 0.05 seconds. 15 PROC PRINT; RUN; NOTE: The PROCEDURE PRINT printed page 1. NOTE: The PROCEDURE PRINT used 0.05 seconds. 16 17 18 *** EXAMPLE 2 ******************************;
  9. 9. 19 *** Data input and means on two variables ***; 20 *** Output statement ***; 21 ********************************************; 22 OPTIONS PS=51 LS=78 NOCENTER NODATE NONUMBER; 23 data one; infile cards; 24 input x y; 25 cards; NOTE: The data set WORK.ONE has 8 observations and 2 variables. NOTE: The DATA statement used 0.05 seconds. 25 run; 34 ; 35 proc means MIN MAX SUM STD USS; var x y; run; NOTE: The PROCEDURE MEANS printed page 2. NOTE: The PROCEDURE MEANS used 0.0 seconds. 36 Proc print data=one; run; NOTE: The PROCEDURE PRINT printed page 3. NOTE: The PROCEDURE PRINT used 0.0 seconds. 37 OPTIONS PS=31 LS=80; 38 Proc plot data=one; plot x*y; run; 39 OPTIONS PS=52; 40 41 *** EXAMPLE 3 ********************; 42 *** Data input, sort and print ***; 43 **********************************; 44 OPTIONS PS=53 LS=79 NOCENTER NODATE NONUMBER; NOTE: The PROCEDURE PLOT printed page 4. NOTE: The PROCEDURE PLOT used 0.0 seconds. 45 DATA NEW3; INFILE CARDS MISSOVER; 46 INPUT day number type $ model $; 47 CARDS; NOTE: The data set WORK.NEW3 has 12 observations and 4 variables. NOTE: The DATA statement used 0.05 seconds. 47 RUN; 60 ; 61 PROC SORT DATA=NEW3; BY type model day number; RUN; NOTE: The data set WORK.NEW3 has 12 observations and 4 variables. NOTE: The PROCEDURE SORT used 0.05 seconds. 62 TITLE1 'My raw data is listed below'; 63 PROC PRINT DATA=NEW3 double; VAR type model day number; RUN; NOTE: The PROCEDURE PRINT printed page 5. NOTE: The PROCEDURE PRINT used 0.0 seconds. 64 65 PROC SORT DATA=NEW3; BY TYPE; RUN; NOTE: Input data set is already sorted, no sorting done. NOTE: The PROCEDURE SORT used 0.0 seconds. 66 TITLE1 'Selected means are provided below'; 67 PROC MEANS DATA=NEW3; BY type; VAR number day; RUN; NOTE: The PROCEDURE MEANS printed page 6. NOTE: The PROCEDURE MEANS used 0.0 seconds. 68 69 PROC SORT DATA=NEW3; BY type; RUN; NOTE: Input data set is already sorted, no sorting done. NOTE: The PROCEDURE SORT used 0.0 seconds. 70 PROC MEANS DATA=NEW3 NOPRINT; BY type; VAR number day; 71 OUTPUT OUT=THREE N=NNo DNo MEAN=NMEAN DMEAN VAR=NVAR DVAR; RUN; NOTE: The data set WORK.THREE has 3 observations and 9 variables. NOTE: The PROCEDURE MEANS used 0.0 seconds.
  10. 10. 72 TITLE1 'Outputted means are listed below'; 73 PROC PRINT DATA=THREE; VAR TYPE NNo DMEAN NVAR DNo NMEAN DVAR; RUN; NOTE: The PROCEDURE PRINT printed page 7. NOTE: The PROCEDURE PRINT used 0.0 seconds. 74 75 76 *** EXAMPLE 4 ********************************************; 77 *** Reading a file and saving a permanent SAS data set ***; 78 **********************************************************; 79 OPTIONS PS=55 LS=77 NOCENTER NODATE NONUMBER; 80 libname mylib 'A:'; NOTE: Libref MYLIB was successfully assigned as follows: Engine: V612 Physical Name: A: 81 DATA mylib.OLD_DATA; INFILE CARDS MISSOVER; 82 INPUT MONTH DAY YEAR STATION $ SPECIES $ NUMBER; 83 LABEL STATION = 'Sample stations'; 84 LABEL SPECIES = 'Species common name'; 85 LABEL STATION = 'Number caught'; 86 CARDS; NOTE: The data set MYLIB.OLD_DATA has 14 observations and 6 variables. NOTE: The DATA statement used 5.21 seconds. 86 RUN; 101 ; 102 103 *** EXAMPLE 5 **************************; 104 *** Reading a permanent SAS data set ***; 105 *** Concatenating SAS data sets ***; 106 ****************************************; 107 OPTIONS PS=55 LS=77 NOCENTER NODATE NUMBER PAGENO=1; 108 libname mylib 'A:'; NOTE: Libref MYLIB was successfully assigned as follows: Engine: V612 Physical Name: A: 109 110 TITLE1 'Example program #5'; 111 DATA NEW_DATA; INFILE CARDS MISSOVER; 112 INPUT MONTH DAY YEAR STATION $ SPECIES $ NUMBER; 113 CARDS; NOTE: The data set WORK.NEW_DATA has 13 observations and 6 variables. NOTE: The DATA statement used 0.05 seconds. 113 RUN; 127 ; 128 DATA MYLIB.ALL_DATA; SET mylib.old_data NEW_DATA; 129 sasdate = mdy(month, day, year); format sasdate date7.; 130 RUN; NOTE: The data set MYLIB.ALL_DATA has 27 observations and 7 variables. NOTE: The DATA statement used 4.55 seconds. 131 PROC SORT DATA=MYLIB.ALL_DATA; BY SPECIES YEAR MONTH DAY; RUN; NOTE: The data set MYLIB.ALL_DATA has 27 observations and 7 variables. NOTE: The PROCEDURE SORT used 4.16 seconds. 132 PROC PRINT DATA=MYLIB.ALL_DATA; 133 TITLE2 'Raw data listing sorted by species y m d'; 134 VAR SPECIES sasdate STATION NUMBER; 135 RUN; NOTE: The PROCEDURE PRINT printed page 1.
  11. 11. NOTE: The PROCEDURE PRINT used 0.0 seconds. 136 PROC FREQ DATA=MYLIB.ALL_DATA; BY SPECIES; WEIGHT NUMBER; 137 TITLE2 'Species frequency (weighted by number)'; 138 TABLE MONTH*STATION; 139 RUN; NOTE: The PROCEDURE FREQ printed pages 2-4. NOTE: The PROCEDURE FREQ used 0.05 seconds. 140 PROC FREQ DATA=MYLIB.ALL_DATA; WEIGHT NUMBER; 141 TITLE2 'Species frequency - chi square test'; 142 TABLE MONTH*STATION / chisq cellchi2 norow nocol nopercent; 143 RUN; NOTE: The PROCEDURE FREQ printed page 5. NOTE: The PROCEDURE FREQ used 0.05 seconds. 144 145 proc plot data=mylib.all_data; 146 TITLE2 'Scatter plot of number by date'; 147 plot number*sasdate=species; 148 run; NOTE: The PROCEDURE PLOT printed page 6. NOTE: The PROCEDURE PLOT used 0.0 seconds. 149 proc chart data=mylib.all_data; by species; 150 TITLE2 'Horizontal bar chart'; 151 hbar species / sumvar=number group=station type=sum; 152 run; NOTE: The PROCEDURE CHART printed pages 7-9. NOTE: The PROCEDURE CHART used 0.05 seconds. 153 OPTIONS PS=30 LS=88; 154 proc chart data=mylib.all_data; 155 TITLE2 'Histogram'; 156 vbar species / sumvar=number type=mean; 157 run; NOTE: The PROCEDURE CHART printed page 10. NOTE: The PROCEDURE CHART used 0.0 seconds. NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414 SAS Output The SAS System OBS STATUS LUSTER HARDNESS TIMEODAY 1 Dried 8 7 Late 2 Dried 8 9 Early 3 Fresh 5 6 Late 4 Fresh 6 3 5 Fresh 7 3 Early The SAS System Variable Minimum Maximum Sum Std Dev USS ------------------------------------------------------------------------------ X 1.0000000 9.0000000 35.0000000 2.6152028 201.0000000 Y 1.0000000 7.0000000 37.0000000 2.0658793 201.0000000 ------------------------------------------------------------------------------
  12. 12. The SAS System OBS X Y 1 1 1 2 2 3 3 3 4 4 4 4 5 4 5 6 5 7 7 7 6 8 9 7 The SAS System Plot of X*Y. Legend: A = 1 obs, B = 2 obs, etc. X ‚ ‚ 9 ˆ A ‚ 8 ˆ ‚ 7 ˆ A ‚ 6 ˆ ‚ 5 ˆ A ‚ 4 ˆ A A ‚ 3 ˆ A ‚ 2 ˆ A ‚ 1 ˆ A ‚ Šƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒˆƒƒ 1 2 3 4 5 6 7 Y My raw data is listed below OBS TYPE MODEL DAY NUMBER 1 CARS COUPE 16 3 2 CARS COUPE 17 2 3 CARS SEDAN 18 3 4 CARS SEDAN 19 1 5 CARS SEDAN 22 5
  13. 13. 6 TRUCKS PICKUP 19 2 7 TRUCKS SEMI 17 9 8 TRUCKS SEMI 18 8 9 TRUCKS SEMI 22 4 10 VANS 4DOOR 17 4 11 VANS 5DOOR 17 1 12 VANS 5DOOR 19 2 Selected means are provided below TYPE=CARS Variable N Mean Std Dev Minimum Maximum -------------------------------------------------------------------- NUMBER 5 2.8000000 1.4832397 1.0000000 5.0000000 DAY 5 18.4000000 2.3021729 16.0000000 22.0000000 -------------------------------------------------------------------- TYPE=TRUCKS Variable N Mean Std Dev Minimum Maximum -------------------------------------------------------------------- NUMBER 4 5.7500000 3.3040379 2.0000000 9.0000000 DAY 4 19.0000000 2.1602469 17.0000000 22.0000000 -------------------------------------------------------------------- TYPE=VANS Variable N Mean Std Dev Minimum Maximum -------------------------------------------------------------------- NUMBER 3 2.3333333 1.5275252 1.0000000 4.0000000 DAY 3 17.6666667 1.1547005 17.0000000 19.0000000 -------------------------------------------------------------------- Outputted means are listed below OBS TYPE NNO DMEAN NVAR DNO NMEAN DVAR 1 CARS 5 18.4000 2.2000 5 2.80000 5.30000 2 TRUCKS 4 19.0000 10.9167 4 5.75000 4.66667 3 VANS 3 17.6667 2.3333 3 2.33333 1.33333 Example program #5 1 Raw data listing sorted by species y m d OBS SPECIES SASDATE STATION NUMBER 1 Croaker 08JAN97 North 3 2 Croaker 15MAY97 North 3 3 Croaker 15MAY97 South 2
  14. 14. 4 Croaker 12AUG97 North 3 5 Croaker 12AUG97 North 9 6 Croaker 14JAN98 North 1 7 Croaker 06MAR98 South 9 8 Croaker 26MAY98 North 12 9 Croaker 29JUL98 North 16 10 Croaker 29JUL98 North 7 11 RedDrum 12AUG97 North 1 12 RedDrum 14JAN98 North 4 13 Spot 08JAN97 North 8 14 Spot 08JAN97 South 11 15 Spot 23MAR97 North 2 16 Spot 23MAR97 South 5 17 Spot 15MAY97 North 1 18 Spot 15MAY97 South 17 19 Spot 12AUG97 North 8 20 Spot 12AUG97 North 8 21 Spot 14JAN98 North 12 22 Spot 14JAN98 South 5 23 Spot 06MAR98 South 3 24 Spot 26MAY98 North 11 25 Spot 26MAY98 South 4 26 Spot 29JUL98 North 24 27 Spot 29JUL98 North 12 Example program #5 2 Species frequency (weighted by number) Species common name=Croaker TABLE OF MONTH BY STATION MONTH STATION(Number caught) Frequency‚ Percent ‚ Row Pct ‚ Col Pct ‚North ‚South ‚ Total ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 1 ‚ 4 ‚ 0 ‚ 4 ‚ 6.15 ‚ 0.00 ‚ 6.15 ‚ 100.00 ‚ 0.00 ‚ ‚ 7.41 ‚ 0.00 ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 3 ‚ 0 ‚ 9 ‚ 9 ‚ 0.00 ‚ 13.85 ‚ 13.85 ‚ 0.00 ‚ 100.00 ‚ ‚ 0.00 ‚ 81.82 ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 5 ‚ 15 ‚ 2 ‚ 17 ‚ 23.08 ‚ 3.08 ‚ 26.15 ‚ 88.24 ‚ 11.76 ‚ ‚ 27.78 ‚ 18.18 ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ
  15. 15. 7 ‚ 23 ‚ 0 ‚ 23 ‚ 35.38 ‚ 0.00 ‚ 35.38 ‚ 100.00 ‚ 0.00 ‚ ‚ 42.59 ‚ 0.00 ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 8 ‚ 12 ‚ 0 ‚ 12 ‚ 18.46 ‚ 0.00 ‚ 18.46 ‚ 100.00 ‚ 0.00 ‚ ‚ 22.22 ‚ 0.00 ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ Total 54 11 65 83.08 16.92 100.00 Example program #5 3 Species frequency (weighted by number) Species common name=RedDrum TABLE OF MONTH BY STATION MONTH STATION(Number caught) Frequency‚ Percent ‚ Row Pct ‚ Col Pct ‚North ‚ Total ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 1 ‚ 4 ‚ 4 ‚ 80.00 ‚ 80.00 ‚ 100.00 ‚ ‚ 80.00 ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 8 ‚ 1 ‚ 1 ‚ 20.00 ‚ 20.00 ‚ 100.00 ‚ ‚ 20.00 ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ Total 5 5 100.00 100.00 Example program #5 4 Species frequency (weighted by number) Species common name=Spot TABLE OF MONTH BY STATION MONTH STATION(Number caught) Frequency‚ Percent ‚ Row Pct ‚ Col Pct ‚North ‚South ‚ Total ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ
  16. 16. 1 ‚ 20 ‚ 16 ‚ 36 ‚ 15.27 ‚ 12.21 ‚ 27.48 ‚ 55.56 ‚ 44.44 ‚ ‚ 23.26 ‚ 35.56 ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 3 ‚ 2 ‚ 8 ‚ 10 ‚ 1.53 ‚ 6.11 ‚ 7.63 ‚ 20.00 ‚ 80.00 ‚ ‚ 2.33 ‚ 17.78 ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 5 ‚ 12 ‚ 21 ‚ 33 ‚ 9.16 ‚ 16.03 ‚ 25.19 ‚ 36.36 ‚ 63.64 ‚ ‚ 13.95 ‚ 46.67 ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 7 ‚ 36 ‚ 0 ‚ 36 ‚ 27.48 ‚ 0.00 ‚ 27.48 ‚ 100.00 ‚ 0.00 ‚ ‚ 41.86 ‚ 0.00 ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 8 ‚ 16 ‚ 0 ‚ 16 ‚ 12.21 ‚ 0.00 ‚ 12.21 ‚ 100.00 ‚ 0.00 ‚ ‚ 18.60 ‚ 0.00 ‚ ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ Total 86 45 131 65.65 34.35 100.00 Example program #5 5 Species frequency - chi square test TABLE OF MONTH BY STATION MONTH STATION(Number caught) Frequency ‚ Cell Chi-Square‚North ‚South ‚ Total ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 1 ‚ 28 ‚ 16 ‚ 44 ‚ 0.441 ‚ 1.1418 ‚ ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 3 ‚ 2 ‚ 17 ‚ 19 ‚ 9.9983 ‚ 25.888 ‚ ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 5 ‚ 27 ‚ 23 ‚ 50 ‚ 2.2805 ‚ 5.905 ‚ ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 7 ‚ 59 ‚ 0 ‚ 59 ‚ 6.3484 ‚ 16.438 ‚ ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ 8 ‚ 29 ‚ 0 ‚ 29 ‚ 3.1204 ‚ 8.0796 ‚ ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ Total 145 56 201
  17. 17. STATISTICS FOR TABLE OF MONTH BY STATION Statistic DF Value Prob ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Chi-Square 4 79.641 0.001 Likelihood Ratio Chi-Square 4 98.373 0.001 Mantel-Haenszel Chi-Square 1 35.363 0.001 Phi Coefficient 0.629 Contingency Coefficient 0.533 Cramer's V 0.629 Sample Size = 201 Example program #5 6 Scatter plot of number by date Plot of NUMBER*SASDATE. Symbol is value of SPECIES. NUMBER ‚ ‚ 24 ˆ S 23 ˆ 22 ˆ 21 ˆ 20 ˆ 19 ˆ 18 ˆ 17 ˆ S 16 ˆ C 15 ˆ 14 ˆ 13 ˆ 12 ˆ S C S 11 ˆ S S 10 ˆ 9 ˆ C C 8 ˆ S S 7 ˆ C 6 ˆ 5 ˆ S S 4 ˆ R S 3 ˆ C C C S 2 ˆ S C 1 ˆ S R C ‚ Šƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒˆƒ 17DEC96 27MAR97 05JUL97 13OCT97 21JAN98 01MAY98 09AUG98 SASDATE NOTE: 1 obs hidden. Example program #5 7 Horizontal bar chart
  18. 18. Species common name=Croaker STATION Species common name NUMBER Freq Sum ‚ North Croaker ‚*************************** 8 54.00000 ‚ South Croaker ‚****** 2 11.00000 ‚ Šƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒ 10 20 30 40 50 NUMBER Sum Example program #5 8 Horizontal bar chart Species common name=RedDrum STATION Species common name NUMBER Freq Sum ‚ North RedDrum ‚************************* 2 5.000000 ‚ Šƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆ 1 2 3 4 5 NUMBER Sum Example program #5 9 Horizontal bar chart Species common name=Spot STATION Species common name NUMBER Freq Sum ‚ North Spot ‚********************************** 9 86.00000 ‚ South Spot ‚****************** 6 45.00000 ‚ Šƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒˆƒƒ 10 20 30 40 50 60 70 80 NUMBER Sum Example program #5 10 Histogram NUMBER Mean ‚ ***** 8 ˆ ***** ‚ ***** ‚ ***** ‚ ***** *****
  19. 19. 6 ˆ ***** ***** ‚ ***** ***** ‚ ***** ***** ‚ ***** ***** 4 ˆ ***** ***** ‚ ***** ***** ‚ ***** ***** ‚ ***** ***** ***** 2 ˆ ***** ***** ***** ‚ ***** ***** ***** ‚ ***** ***** ***** ‚ ***** ***** ***** Šƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Croaker RedDrum Spot Species common name

×