/* --------------------------Exercise 11.6 & 12.6 ------------------------------------------------- */ data sg.MN_116; input MPG @@; datalines; 24 14 25 30 28 26 32 28 28 34 27 26 23 24 28 34 29 23 26 26 27 24 25 27 27 28 19 28 29 28 28 ; proc print; run; /*filename odsout 'C:\Documents and Settings\nahtman\Mina dokument\t2.htm'; ods listing close; ods html file=odsout style=gears;*/ /*proc univariate data=MN_116; histogram mpg / cframe = ligr cfill = blue; run; */ *ods select HistogramBins MyHist; title 'The highway fuel consumption (midsize cars)'; ods html; proc univariate data=sg.MN_116; histogram mpg / /*midpercents*/vscale=percent VAXIS=(0 10 20 30 40 60) /*midpoints = 16 to 32 by 4*/ endpoints=14 to 32 by 4 ; run; ods html close; ods html; proc univariate plot data=sg.MN_116 noprint; histogram mpg / midpercents VREF = (5 10 15) vscale = count VAXIS=(0 5 10 15 20) midpoints = 16 to 32 by 4; run; ods html close; /* title 'The highway fuel consumption (midsize cars)'; proc univariate data=MN_116; histogram mpg / midpoints = 15 to 33 by 2 rtinclude; run; PROC UNIVARIATE PLOT data=MN_116 PLOTSIZE=34; VAR mpg; RUN; */ goptions reset=all; /*ods html close; ods listing;*/ /* --------------------------- 11.8 ----------------------------------------- */ data sg.MN_118; input salary; datalines; 22000000 18600000 16000000 15714286 13000000 12428571 12357142 10890000 9000000 9000000 8500000 7000000 6000000 3100000 3000000 2700000 2000000 1925000 1800000 1000000 900000 775000 750000 700000 500000 450000 302550 301400 ; *proc print; *run; title 'Salaries of the New Yourk Yankees, 2004'; /*ods html; proc univariate data=sg.MN_118; histogram salary / cframe = ligr cfill = blue; run; ods html close;*/ ods html; proc univariate data=sg.MN_118; histogram salary/ midpercents endpoints = 0 to 22000000 by 4000000; run; proc univariate data=sg.MN_118; histogram salary / midpoints = 1000000 to 21000000 by 4000000 rtinclude; run; ods html close; *goptions reset=all; /* --------------------------------------------------------------------------- */ data sg.MN_119; input length percent; i=_N_; x=10*percent; datalines; 1 3.6 2 14.8 3 18.7 4 16 5 12.5 6 8.2 7 8.1 8 5.9 9 4.4 10 3.6 11 2.1 12 0.9 13 0.6 14 0.4 15 0.2 ; title 'Distribution of the lengths of words'; proc freq data=sg.MN_119; weight x; tables length/ out=ord OUTCUM; run; proc print; proc univariate data=ord; freq count; histogram length / /*cframe = blue*/ cfill = ligr; run; /* symbol interpol=join l=1 w=2; proc gplot data = ord; plot cum_pct*length/ vref=50; run; quit; goptions reset = all;ods html close;*/ /* --------------------------------------------------------------------------- */ data sg.MN_1114; input age_group year_1950 year_2075; datalines; 1 29.3 34.9 2 21.8 35.7 3 24 36.8 4 22.8 38.1 5 19.3 37.8 6 15.5 37.5 7 11 34.5 8 5.5 27.2 9 1.6 18.8 10 0.1 7.7 11 . 1.7 ; proc freq data=sg.MN_1114; weight year_1950; tables age_group/ out=FreqCnt; title1 'Age distribution in the Unated States. 1950 and 2075'; run; /*proc print data=FreqCnt noobs;title2 'Output Data Set from PROC FREQ';run;*/ proc freq data=sg.MN_1114; weight year_2075 ; tables age_group/ out=FreqCnt1 outexpect sparse; title1 'Age distribution in the Unated States. 1950 and 2075'; run; /*proc print data=FreqCnt1 noobs;title2 'Output Data Set from PROC FREQ';run;*/ /*title 'Age distribution in the Unated States. 1950'; proc univariate data=FreqCnt; freq count; histogram age_group / cframe = ligr cfill = blue; run; proc univariate data=FreqCnt; freq count; histogram age_group/ midpercents cframe = ligr cfill = blue endpoints = 1 to 11 by 1; run;*/ ods html; title 'Age distribution in the Unated States, 1950'; proc univariate data=FreqCnt; freq count; histogram age_group/ midpoints = 1 to 10 by 1 rtinclude; run; title 'Age distribution in the Unated States, 2075'; proc univariate data=FreqCnt1; freq count; histogram age_group / /* cframe = ligrcfill = blue*/ VAXIS=(0 2.5 5 7.5 10 12.5 15 17.5 20); run; ods html close; /* --------------------------Exercise 11.9 ------------------------------------------------- */ data sg.MN_119; input ord percent; i=_N_; x=10*percent; datalines; 1 3.6 2 14.8 3 18.7 4 16 5 12.5 6 8.2 7 8.1 8 5.9 9 4.4 10 3.6 11 2.1 12 0.9 13 0.6 14 0.4 15 0.2 ; proc print; run; proc freq data=sg.MN_119; weight x; tables ord/ out=ord outexpect sparse; title1 'Distribution of the lengths of words'; run;proc print; proc univariate data=ord; freq count; histogram ord / cfill = ligr; run; /* --------------------------Exercise 12.9 ------------------------------------------------- */ data sg.MN_129; input calories; datalines; 173 191 182 190 172 147 146 139 175 136 179 153 107 195 135 140 138 ; ods html ; PROC UNIVARIATE PLOT data=sg.MN_129 ; VAR calories; RUN; ods html close; /* --------------------------Exercise 12.12 ------------------------------------------------- */ /* data sg.MN_1212; input p ord; count=p*10; datalines; 3.6 1 14.8 2 18.7 3 16 4 12.5 5 8.2 6 8.1 7 5.9 8 4.4 9 3.6 10 2.1 11 0.9 12 0.6 13 0.4 14 0.2 15 ; run; goptions reset=all gunit=pct border cback=white colors=(black blue green red) ftitle=swissb ftext=swiss htitle=5 htext=3.5; /* Define title title1 'The statistics of writing styles'; footnote h=3 j=r 'Moore & Notz'; /* Modify axes axis1 label=('The lengths of words' j=c) minor=(number=1); axis2 label=('Percent' j=r 'Group'); /* Define pattern characteristics pattern1 color=cyan; proc gchart data=sg.MN_1212; *vbar ord/freq=count sumvar=p NOZERO; *block ord/NOHEADING freq=count sumvar=p midpoints= 1 to 15 by 1 ; run ; quit; */ /* ------------------------Exercise 12.20 ------------------------------------- */ data sg.MN_1220; input mpg; datalines; 21 19 18 18 18 19 22 18 21 19 21 21 20 20 16 17 17 23 18 19 19 20 27 22 27 21 ; ods html; title 'The highway fuel consumption (SUV)'; PROC UNIVARIATE data=sg.MN_1220 PLOTSIZE=27; histogram mpg / midpercents VAXIS=(0 10 20 30 40 50 60) endpoints = 14 to 34 by 4 rtinclude ; *VAR mpg; RUN; PROC UNIVARIATE PLOT data=sg.MN_1220 PLOTSIZE=27; histogram mpg / midpercents vscale=percent VAXIS=(0 5 10 15 20) /*endpoints = 14 to 34 by 4*/midpoints=16 to 36 by 4 rtinclude ; *VAR mpg; RUN; ods html close; title 'The highway fuel consumption (SUV)'; ods select BasicMeasures Quantiles; proc univariate data=sg.MN_1220; var mpg; run; title 'The highway fuel consumption (midsize cars)'; ods select BasicMeasures Quantiles; proc univariate data=sg.MN_116; var mpg; run; Data sg.MN_MPG; set sg.MN_116 sg.MN_1220; size='Midsize'; if _N_>31 then size='SUV'; proc print; run; ods html style=gears; proc means data=sg.MN_MPG mean q1 median q3 min max; var mpg; by size; run; ods graphics on; symbol1 v=plus c=salmon; symbol2 v=square c=vigb; symbol3 v=triangle c=vig; title 'MPG (The highway fuel consumption, miles per gallon)'; proc boxplot data=sg.MN_MPG; plot MPG*size / cboxes = dagr cboxfill = ywh cframe = vligb; * inset / height=6 cfill=ywh header='Midsize cars: 26.6' pos=w ; *inset mean / pos = ne format = 6.3 cfill = ywh; label MPG = 'Fuel consumption'; label size = 'Car size'; run; ods graphics off; ods html close; data iu1; set sg.inuppgift2; proc print; run; proc sort data=iu1; by opinion; run; ods html; proc univariate data=iu1; class opinion; histogram age /vscale=count cfill = blue cframe = ligr endpoints = 20 to 50 by 5; inset n mean; run; ods html close;