/* En kommun planerar att bygga ett hus för kulturella ändamål. Huset skall innehålla utrymmen för teater, konstutställningar, musikframträdanden etc. För att undersöka invånarnas inställning till ett sådant hus har en urvalsundersökning genomförts. Filen innehåller svar från 210 slumpvis utvalda personer om deras inställning till att bygga ett hus. Filen innehåller också uppgifter om personernas ålder, kön och inkomst. kön: 0: mot "man"; 1: "kvinna". inställning till husbygget: 0: "är emot ett bygge"; 1: "är för ett bygge". Beskriv varje variabel för sig, både numeriskt och grafiskt. Analysera även materialet med avseende på inställning till husbygget. */ data sg.iu1; set sg.inuppgift2; if (gender=0) AND (opinion=0) then op_g= 'Against, M'; else if (gender=0) AND (opinion=1) then op_g= 'For, M'; else if (gender=1) AND (opinion=0) then op_g= 'Against, F'; else if (gender=1) AND (opinion=1) then op_g= 'For, F'; if age<26 then ageclass=1; else if (age>25) AND (age<31) then ageclass=2; else if (age>30) AND (age<36) then ageclass= 3; else if (age>35) AND (age<41) then ageclass=4; else if age>40 then ageclass=5; if income<24000 then income_c=1; else if (income>23000) AND (income<27000) then income_c=2; else if (income>26000) AND (income<30000) then income_c= 3; else if income>30000 then income_c=4; *LABEL gender = "0: male 1: female" opinion = "0: är emot ett bygge 1: är för ett bygge"; *proc print; run; PROC FORMAT; VALUE genderf 0="Male" 1="Female"; VALUE opinionf 0="Against" 1="For"; VALUE agef 1="- 24" 2="25-34" 3="35-44" 4="45-54" 5="55-"; /* VALUE $makef "AMC" ="American Motors" "Buick" ="Buick (GM)" "Cad." ="Cadillac (GM)" "Chev." ="Chevrolet (GM)" "Datsun" ="Datsun (Nissan)";*/ RUN; proc sort data=sg.iu1 out = gen_op; by gender opinion; run; ods html; proc univariate data=gen_op plot; FORMAT gender genderf. opinion opinionf.; var income age; *by gender opinion; run; proc freq data=sg.iu1; tables gender*opinion/chisq out=FreqCnt OUTPCT; tables ageclass*opinion/chisq; tables income_c*opinion/chisq; run; title Distribution of Income and Age with respect to Gender ; symbol2 i=none v= > h=1 c=red; symbol1 i=none v= * h=1 c=green; symbol4 i=none v= > h=1 c=blue; symbol3 i=none v= * h=1 c=black; /* define horizontal axis characteristics */ axis1 label=(h=1.5 'Age') major=(h=0.5) minor=none; /* vertical axis characteristics */ axis2 label=(h=1.5 'Income') major=(h=0.5) minor=none; *symbol1 color=black interpol=none height=2.5 value=circle; proc gplot data = sg.iu1; FORMAT gender genderf. opinion opinionf.; *plot income*age=gender/frame haxis=axis1 vaxis=axis2; plot income*age=op_g/frame haxis=axis1 vaxis=axis2; run; quit; goptions reset = all; ods html close; ods html; title Distribution of Income and Age with respect to Opinion ; symbol1 i=none value=dot h=0.5 c=red; symbol2 i=none v=star h=1 c=blue; /* define horizontal axis characteristics */ axis1 label=(h=1.5 'Age') major=(h=0.5) minor=none; /* vertical axis characteristics */ axis2 label=(h=1.5 'Income') major=(h=0.5) minor=none; *symbol1 color=black interpol=none height=2.5 value=circle; proc gplot data = sg.iu1; FORMAT gender genderf. opinion opinionf.; *plot income*age=gender/frame haxis=axis1 vaxis=axis2; plot income*age=opinion/frame haxis=axis1 vaxis=axis2; run; quit; goptions reset = all; ods html close; ods html; title Distribution of Income and Age with respect to Opinion ; symbol1 i=none value= > h=0.5 c=red; symbol2 i=none v= * h=0.5 c=blue; /* define horizontal axis characteristics */ axis1 label=(h=0.5 'Age') major=(h=0.5) minor=none; /* vertical axis characteristics */ axis2 label=(h=0.5 'Income') major=(h=0.5) minor=none; *symbol1 color=black interpol=none height=2.5 value=circle; proc gplot data = sg.iu1; FORMAT gender genderf. opinion opinionf.; *plot income*age=gender/frame haxis=axis1 vaxis=axis2; plot income*age=gender/frame haxis=axis1 vaxis=axis2; run; quit; goptions reset = all; ods html close; proc ttest data=sg.iu1 /*H0=800 ALPHA=0.05*/; FORMAT gender genderf. opinion opinionf.; class gender; var income age; run; proc ttest data=sg.iu1 /*H0=800 ALPHA=0.05*/; FORMAT gender genderf. opinion opinionf.; class opinion; var income age; run; /* . Sjukfrånvaron i en population framgår av nedanstående tabell. Jämför sjukfrånvaron för män och kvinnor. Jämförelsen skall göras både med och utan hänsyn till olikheter i åldersfördelningen. Vilka slutsatser kan dras? */ data new; input age count day gender; datalines; 1 94 2 0 1 43 3 1 2 80 4 0 2 67 6 1 3 49 4 0 3 71 5 1 4 38 6 0 4 73 5 1 5 40 9 0 5 58 5 1 ; proc print; run; proc freq data=new; FORMAT gender genderf. age agef.; weight count; tables day*gender; *by age; run; proc sort data=new; by gender; run; proc ttest data=new H0=4 ALPHA=0.05; FORMAT gender genderf.; freq count; var day; by gender; run; proc ttest data=new; FORMAT gender genderf.; class gender; freq count; var day; run; proc sort data=new; by age; run; proc freq data=new; FORMAT gender genderf. age agef.; weight number; tables day*gender; by age; run; proc freq data=new; FORMAT gender genderf. age agef.; weight number; tables day*gender/chisq; run; proc sort data=new; by gender; run; proc freq data=new; FORMAT gender genderf. age agef.; weight number; tables day*age; by gender; run; ods html; proc univariate data=new; FORMAT gender genderf. age agef.; class gender; freq number; histogram day /vscale=count cfill = blue cframe = ligr endpoints = 0 to 10 by 1; inset n mean; run; ods html close; /*----------------- Uppgift 3a --------------------------*/ /* Sjuktalet definieras som antal dagar med sjukpenning under ett år per sjukförsäkrad. I tabellen nedan framgår sjuktalen för kvinnor i Stockholm och i Malmö för ett visst år. Jämför sjuktalen för de två områdena. Jämförelsen skall göras både med och utan hänsyn till olikheter i åldersfördelningen. Vilka slutsatser kan dras? */ data up3_a; length city $ 10; input age$ city $ Insured ill; n=ill*insured; datalines; 16-19 Stockholm 36500 18.0 16-19 Malmo 5700 16.8 20-29 Stockholm 115600 23.7 20-29 Malmo 17700 25.5 30-39 Stockholm 125100 22.1 30-39 Malmo 15300 27.4 40-49 Stockholm 81500 27.1 40-49 Malmo 13600 28.6 50-59 Stockholm 94000 36.6 50-59 Malmo 17600 34.8 60-64 Stockholm 43700 36.8 60-64 Malmo 8500 35.8 ; proc print; run; /*modify oxygen; rename oxygen=intake; label intake='Intake Measurement'; quit;*/ proc sort data=up3_a; by city; run; ods html; proc univariate data=up3_a; *FORMAT gender genderf. age agef.; class city; *freq number; histogram n /vscale=count cfill = blue cframe = ligr endpoints = 50000 to 3500000 by 500000; inset n mean; run; ods html close; ods html; *symbol1 i=join value= star pointlabel=(h=1.5 '#n') h=0.5 c=red l=1; symbol1 i=join value= star pointlabel=(h=1 '#n') h=0.5 c=red l=1; symbol2 i=join v=triangle pointlabel=(h=1 '#n') h=0.5 c=blue; /* define horizontal axis characteristics */ axis1 label=(h=0.5 'Age' ) major=(h=0.5) minor=none; /* vertical axis characteristics */ axis2 label=(h=0.5 'N_Ill' ) major=(h=0.5) minor=none; *symbol1 color=black interpol=none height=2.5 value=circle; proc gplot data = up3_a; *FORMAT gender genderf. opinion opinionf.; *plot income*age=gender/frame haxis=axis1 vaxis=axis2; plot n*age=city/frame haxis=axis1 vaxis=axis2; run; quit; goptions reset = all; ods html close;