Docsity

SAS Analysis of Fuel Consumption and Driving Licenses Data - Prof. Mervyn G. Marasinghe, Study notes of Statistics

Toggle sidebar
bg1
Example B9
SAS PROGRAM
options formchar="|----|+|---+=|-/\<>*";
libname mylib 'C:\Documents and Settings\mervyn\My Documents\Classwork\stat479\';
data fueldat2;
set mylib.fueldat;
if fuel=<525 then fuelgrp=1;
else if 525<fuel=<610 then fuelgrp=2;
else fuelgrp=3;
if percent=<54 then licgrp=1;
else if 54<percent=<58 then licgrp=2;
else licgrp=3;
label licgrp='% Driving Licenses'
fuelgrp='Fuel Consumption';
run;
proc format;
value lg 1='below 54%'
2='54 to 58%'
3='above 58%' ;
value fg 1 = 'Low Fuel Use'
2 = 'Medium Fuel Use'
3 = 'High Fuel Use';
value ing 1 = 'Low Income'
2 = 'Middle Income'
3 = 'High Income';
run;
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download SAS Analysis of Fuel Consumption and Driving Licenses Data - Prof. Mervyn G. Marasinghe and more Study notes Statistics in PDF only on Docsity!

Example^ B9 SAS^ PROGRAM options^ formchar="|----|+|---+=|-/<>*";libname^ mylib^ 'C:\Documents and Settings\mervyn\My Documents\Classwork\stat479'; data^ fueldat2;set^ mylib.fueldat;if fuel=<^525 then^ fuelgrp=

else^ if^^525 <fuel=<^610 then

fuelgrp=^2 ; else^ fuelgrp=^3 ; if percent=<^54 then^ licgrp=

else^ if^^54 <percent=<^58 then

licgrp=^2 ; else^ licgrp=^3 ; label^ licgrp='% Driving Licenses'fuelgrp='Fuel Consumption'; run ; proc^ format ; value^ lg^^1 ='below 54%'^2 ='54 to 58%'^3 ='above 58%'

; value fg 1 = 'Low Fuel Use' 2 = 'Medium Fuel Use' 3 = 'High Fuel Use';value ing 1 = 'Low Income' 2 = 'Middle Income' 3 = 'High Income'; run ;

proc^ freq^ data=fueldat2;tables^ fuelgrp*(taxgrp incomgrp)/chisq

expectedcellchi2 nocol nopercent norow; tables^ fuelgrp*licgrp/chisq

expected^ nocol^ nopercent

norow^ measures; tables^ taxgrp*fuelgrp/list

format^ fuelgrp^ fg.^ licgrp

lg.^ incomgrp^ ing.^ ; title^ 'Output from the first Proc Freq step'; run ; proc^ freq^ data=fueldat2;tables^ fuelgrp*licgrp/chisq

expected^ nocol^ nopercent

norow^ measures; test^ gamma^ scorr;format^ fuelgrp^ fg.^ licgrp

lg.^ incomgrp^ ing.^ ; title^ 'Output from the second Proc Freq step'; run ; proc^ freq^ data=fueldat2;tables^ fuelgrp*licgrp/chisq

expected^ nocol^ nopercent

norow^ exact; format^ fuelgrp^ fg.^ licgrp

lg.^ incomgrp^ ing.^ ; title^ 'Output from the third Proc Freq step'; run ;

1920 proc^ format; 21 value^ lg 1='below 54%' 22 2='54^ to 58%' 23 3='above

58%'^ ;

NOTE:^ Format^ LG^ has^ been^

output. 24 value^ fg^1 =^ 'Low

Fuel^ Use' 25 2 =^ 'Medium

Fuel^ Use' 26 3 = 'High Fuel

Use'; NOTE:^ Format^ FG^ has^ been^

output. 27 value^ ing^1 =^ 'Low

Income' 28 2 =^ 'Middle

Income' 29 3 =^ 'High

Income'; NOTE:^ Format^ ING^ has been output. 30 run;NOTE:^ PROCEDURE^ FORMAT used (Total

process^ time): real^ time^ 0.06 secondscpu^ time^ 0.00 seconds 3132 proc^ freq^ data=fueldat2; 33 tables^ fuelgrp*(taxgrp^

incomgrp)/chisq^ expected 34 cellchi

nocol^ nopercent^ norow; 35 tables^ fuelgrp*licgrp/chisq

expected^ nocol nopercent norow measures; 36 tables^ taxgrp*fuelgrp/list ; 37 format^ fuelgrp^ fg.

licgrp^ lg.^ incomgrp^ ing.

38 title^ 'Output^ from

the^ first^ Proc^ Freq^ step'; 39 run;NOTE:^ There^ were^48 observations read

from^ the^ data^ set^ WORK.FUELDAT2. NOTE:^ PROCEDURE^ FREQ^ used

(Total process^ time):

4142 proc^ freq^ data=fueldat2; 43 tables^ fuelgrp*licgrp/chisq

expected^ nocol nopercent norow measures; 44 test^ gamma scorr; 45 format^ fuelgrp^ fg.

licgrp^ lg.^ incomgrp^ ing.

46 title^ 'Output^ from

the^ second^ Proc Freq^ step'; 47 run;NOTE:^ There^ were^48 observations read

from^ the^ data^ set^ WORK.FUELDAT2. NOTE:^ PROCEDURE^ FREQ^ used

(Total process^ time):real time 0.01 secondscpu time 0.00 seconds 484950 proc^ freq^ data=fueldat2; 51 tables^ fuelgrp*licgrp/chisq

expected^ nocol nopercent

norow exact; 52 format^ fuelgrp^ fg.

licgrp^ lg.^ incomgrp^ ing.

53 title^ 'Output^ from

the^ third^ Proc^ Freq^ step'; 54 run;NOTE:^ There^ were^48 observations read

from^ the^ data^ set^ WORK.FUELDAT2. NOTE:^ PROCEDURE^ FREQ^ used

(Total process^ time):real time 0.07 secondscpu time 0.01 seconds

Statistics^ for^ Table^ of^

fuelgrp^ by^ taxgrp Statistic^

DF^ Value^ Prob ------------------------------------------------------Chi-Square^

2 9.3275^ 0.

Likelihood^ Ratio Chi-Square

2 10.2233^ 0.

Mantel-Haenszel Chi-Square

1 7.2412^ 0.

Phi^ Coefficient^

Contingency^ Coefficient^

Cramer's^ V^

0.4408Sample Size = 48

Output^ from^ the^ first^ Proc

Freq^ step^

The^ FREQ^ ProcedureTable of^ fuelgrp^ by^ incomgrpfuelgrp(Fuel Consumption)^ incomgrp(Per

capita^ Income) Frequency^ | Expected^ | Cell^ Chi-Square^ |Low^ Inco|Middle

I|High^ Inc|^ Total|me |ncome |ome^ | ----------------+--------+--------+--------+Low^ Fuel^ Use^ |^1

|^3 |^12 |^16 | 4.3333 |^ 6 | 5.6667 || 2.5641 |^ 1.5 | 7.0784 |

----------------+--------+--------+--------+Medium Fuel Use^ |^8

|^7 |^2 |^17 | 4.6042 |^ 6.375 | 6.0208 || 2.5046 |^ 0.0613^ |^ 2.6852 |

----------------+--------+--------+--------+High^ Fuel^ Use^ |^4

|^8 |^3 |^15 | 4.0625 |^ 5.625 | 5.3125 || 0.001 |^ 1.0028^ |^ 1.0066^ |

----------------+--------+--------+--------+Total^13

Output^ from^ the^ first^ Proc

Freq^ step^

The^ FREQ^ ProcedureTable of fuelgrp^ by^ licgrpfuelgrp(Fuel Consumption)^ licgrp(% Driving Licenses)Frequency | Expected |below^ 54|54^ to^ 58|above^ 58|

Total |%^ |%^ |%^

----------------+--------+--------+--------+Low^ Fuel^ Use^ |^6

|^9 |^1 |^16 | 4.6667 |^ 6 | 5.3333 |

----------------+--------+--------+--------+Medium Fuel Use^ |^7

|^5 |^5 |^17 | 4.9583 |^ 6.375 | 5.6667 |

----------------+--------+--------+--------+High^ Fuel^ Use^ |^1

|^4 |^10 |^15 | 4.375 |^ 5.625^ |^5 |

----------------+--------+--------+--------+Total^14

Statistics^ for^ Table^ of^

fuelgrp^ by^ licgrp Statistic^

DF^ Value^ Prob ------------------------------------------------------Chi-Square^

4 14.6905^ 0.

Likelihood^ Ratio^ Chi-Square

4 16.2966^ 0.

Mantel-Haenszel Chi-Square

1 9.9989^ 0.

Phi^ Coefficient^

Contingency^ Coefficient^

Cramer's^ V^

WARNING:^ 33%^ of^ the^ cells

have^ expected^ counts^ lessthan 5. Chi-Square may^ not be a valid test.

Cumulative^ Cumulative

taxgrp^ fuelgrp

Frequency^ Percent

Frequency^ Percent ------------------------------------------------------------------------------High^ Low^ Fuel^ Use^

10 20.^

High^ Medium^ Fuel^ Use

10 20.^

High^ High^ Fuel^ Use^

2 4.^

Low^ Low^ Fuel^ Use^

6 12.^

Low^ Medium^ Fuel^ Use

7 14.^

Low^ High^ Fuel^ Use^

13 27.^

Output^ from^ the^ second^ Proc

Freq^ step^

The^ FREQ^ ProcedureTable of fuelgrp^ by^ licgrpfuelgrp(Fuel Consumption)^ licgrp(% Driving Licenses)Frequency | Expected |below^ 54|54^ to^ 58|above^ 58|

Total |%^ |%^ |%^

----------------+--------+--------+--------+Low^ Fuel^ Use^ |^6

|^9 |^1 |^16 | 4.6667 |^ 6 | 5.3333 |

----------------+--------+--------+--------+Medium Fuel Use^ |^7

|^5 |^5 |^17 | 4.9583 |^ 6.375 | 5.6667 |

----------------+--------+--------+--------+High^ Fuel^ Use^ |^1

|^4 |^10 |^15 | 4.375 |^ 5.625^ |^5 |

----------------+--------+--------+--------+Total^14

Output^ from^ the^ second^ Proc

Freq^ step^

The^ FREQ^ ProcedureStatistics for^ Table^ of^ fuelgrp^ by^ licgrpStatistic Value

ASE

------------------------------------------------------Gamma^

0.5641^ 0.

Kendall's^ Tau-b^

0.4024^ 0.

Stuart's^ Tau-c^

0.4010^ 0.

Somers'^ D^ C|R^

0.4016^ 0.

Somers'^ D^ R|C^

0.4031^ 0.

Pearson^ Correlation^

0.4612^ 0.

Spearman^ Correlation^

0.4640^ 0.

Lambda^ Asymmetric^ C|R^

0.2667^ 0.

Lambda^ Asymmetric^ R|C^

0.2903^ 0.

Lambda^ Symmetric^

0.2787^ 0.

Uncertainty^ Coefficient C|R

0.1553^ 0.

Uncertainty^ Coefficient R|C

0.1547^ 0.

Uncertainty^ Coefficient Symmetric

0.1550^ 0.

  • Gamma--------------------------------Gamma 0.5641ASE 0.127295% Lower Conf Limit 0.314895% Upper Conf Limit 0.8134Test of H0: Gamma =^0 ASE under H0 0.1390Z 4.0587One-sided Pr > Z <.0001Two-sided Pr > |Z| <.

Output^ from^ the^ third^ Proc

Freq^ step^

The^ FREQ^ ProcedureTable of fuelgrp^ by^ licgrpfuelgrp(Fuel Consumption)^ licgrp(% Driving Licenses)Frequency | Expected |below^ 54|54^ to^ 58|above^ 58|

Total |%^ |%^ |%^

----------------+--------+--------+--------+Low^ Fuel^ Use^ |^6

|^9 |^1 |^16 | 4.6667 |^ 6 | 5.3333 |

----------------+--------+--------+--------+Medium Fuel Use^ |^7

|^5 |^5 |^17 | 4.9583 |^ 6.375 | 5.6667 |

----------------+--------+--------+--------+High^ Fuel^ Use^ |^1

|^4 |^10 |^15 | 4.375 |^ 5.625^ |^5 |

----------------+--------+--------+--------+Total^14

Statistics^ for^ Table^ of^

fuelgrp^ by^ licgrp Statistic^

DF^ Value^ Prob ------------------------------------------------------Chi-Square^

4 14.6905^ 0.

Likelihood^ Ratio^ Chi-Square

4 16.2966^ 0.

Mantel-Haenszel Chi-Square

1 9.9989^ 0.

Phi^ Coefficient^

Contingency^ Coefficient^

Cramer's^ V^

WARNING:^ 33%^ of^ the^ cells

have^ expected^ counts^ lessthan 5. Chi-Square may^ not be a valid test.Fisher's Exact^ Test----------------------------------Table Probability^ (P)^ 5.544E-06Pr <= P 0.0046Sample Size^ =^48