data ex18_1; input category $ frequency; datalines; A 20 B 30 C 30 D 20 ; proc freq data=ex18_1; weight frequency; tables category / nocum testf=(25 25 25 25) chisq expected cellchi2 norow nocol; title 'Likformig fördelning över kategorierna?'; run; goptions reset=all; data ex18_2; input lower_l upper_l mp f; f1=f*10; mp1=(mp-1.53)*10; lower_l1=(lower_l-1.53)*10; upper_l1=(upper_l-1.53)*10; mp2=(lower_l1+upper_l1)/2; q_upper=cDF('NORMAL',upper_l1); q_lower=cDF('NORMAL',lower_l1); diff=q_upper-q_lower; expected=100*diff; datalines; 0 1.275 0.6375 0 1.275 1.325 1.3 1 1.325 1.375 1.35 6 1.375 1.425 1.4 9 1.425 1.475 1.45 15 1.475 1.525 1.5 13 1.525 1.575 1.55 22 1.575 1.625 1.6 19 1.625 1.675 1.65 9 1.675 1.725 1.7 2 1.725 1.775 1.75 4 1.775 1000 1.8 0 ; proc print; /* 0,54, 1,48, 4,04, 8,63, 14,43, 18,89, 19,35, 15,03, 9,76, 4,79, 1,85, 0,71 */ run; proc means data=ex18_2; freq f; var mp2; run; proc freq data=ex18_2; weight f/ZEROS; tables mp/nocum testp=(0.898845313 0.008569048 0.00801986 0.007487132 0.006972341 0.006476737 0.006001342 0.005546958 0.005114178 0.004703393 0.004314804 0.037948895) chisq expected cellchi2 norow nocol; run; proc univariate data=ex18_2; freq f1; var mp1; run; data ex18_3; input education$ marriage$ Count; datalines; grundskola 0 18 grundskola 1 29 grundskola 2 70 grundskola 3 115 gymnasium 0 17 gymnasium 1 28 gymnasium 2 30 gymnasium 3 41 university 0 11 university 1 10 university 2 11 university 3 20 ; proc sort data=ex18_3; by education marriage; run; proc freq data=ex18_3 order=data; weight Count; tables education*marriage / chisq expected cellchi2 nocum norow nocol; title 'Finns det samband mellan en skolutbildning och inställning till äktenskapet?'; run; goptions reset=all; data ex18_4; input q1$ q2$ Count; datalines; ja ja 80 ja nej 25 nej ja 80 nej nej 15 ; proc freq data=ex18_4 order=data; weight Count; tables q1*q2 / chisq expected cellchi2 nocum norow nocol; title 'Är den första frågan (Q1) oberoende av om man är rökare eller ej?'; run; goptions reset=all; data ex24_2; input parent_sm$ student_sm$ Count; datalines; both yes 400 both no 1380 one yes 416 one no 1823 neither yes 188 neither no 1168 ; proc freq data=ex24_2 order=data; weight Count; tables parent_sm*student_sm / chisq expected cellchi2 nocum norow nocol; run; data ex24_14; input stress_m$ heart$ Count; datalines; ja ja 3 ja nej 30 nej ja 7 nej nej 27 vanlig ja 12 vanlig nej 28 ; proc print; run; proc freq data=ex24_14 order=data; weight Count; tables stress_m*heart / chisq expected cellchi2 nocum norow nocol; run; data ex24_15; input city$ care$ Count; datalines; Newark ja 42 Newark nej 31 Camden ja 29 Camden nej 72 S_chicago ja 48 S_chicago nej 59 ; proc freq data=ex24_15 order=data; weight Count; tables city*care / chisq expected cellchi2 nocum norow nocol; run;