2 Code Hypotesistest.sas

.pdf
/* Load Data*/ FILENAME REFFILE '/home/u63510467/3316/ncbirth1450.csv' ; /* import data*/ PROC IMPORT DATAFILE =REFFILE DBMS =CSV /* data extension*/ OUT =birth; /* a name for you data, you can pick any name you like*/ GETNAMES =YES; RUN ; /* Print Data, uncomment it if you want to print the data*/ /*proc print DATA=birth; run;*/ /* run t-test */ proc ttest alpha = 0.05 data =birth sides =U h0 = 25 ; /* alpha: significance level */ /* data: birth */ /* sides: U=right-sided, L=left-sideds, 2=two-sided */ /* h0: mu=25, null hypothesis, h1: mu>25, alternative hypothesis*/ var mage; run ; /* run t-test*/ data critical; /*critical value in t-test*/ tc= tinv ( 0.95 , 1449 ); /* get the critical value at confidence level C=0.95, and the freedom of t distribution is 1450*/ /* 1450 is the number of observations*/ proc print data =critical; /* print the critical value*/ run ; /* follow the procedures above to finish question (b) and (c)*/ proc ttest alpha = 0.95 data =birth sides =L h0 = 39 ; var weeks; run ; proc ttest alpha = 0.95 data =birth sides =U h0 = 112 ; var tounces; run ; /* side-by-side boxplot for question (d)*/ proc sgplot data =birth; vbox tounces / category = smoke; title 'Tounces by smoke' ; run ; /* z-test for proportion in question (e) and (f)*/ /* np>=10 and n(1-p)>=10* normality test*/ proc freq data =birth; tables LOW/ binomial ( p = 0.06 ); run ; proc freq data =birth; tables SMOKE/ binomial ( p = 0.1 ); run ; /* please read: https://support.sas.com/kb/22/561.html */ /* you will get the idea of one-sided test and know how to deal with (h)*/ /* question (i), similar as question (h), do it yourself*/ /*CODE STARTS HERE*/ /* delete all of the null spaces*/ data no_null; set birth; if GAINED ne '#NULL' ; if WEEKS ne '#NULL' ; if TOUNES ne '#NULL' ; if MAGE ne '#NULL' ; if SMOKE ne '#NULL' ; if DRINK ne '#NULL' ; RUN ; /*frequency table for % of low birth weights*/ proc freq data =birth; tables LOW / out =low_freq; RUN ; /*frequency table for the % of smokers*/ proc freq data =birth; tables SMOKE / out =low_smoke; RUN ; /*summary table (mean, median, standard deviation, minimum, maximum) continuous variables of mage, weeks, and tounces*/ proc means data =birth mean median std max min ; var MAGE; output out =sumtab_mage; RUN ; proc means data =birth mean median std max min ; var WEEKS; output out =sumtab_weeks; RUN ; proc means data =birth mean median std max min ; var TOUNCES; sumtab_tounces Code: Hypotesis_test.sas https://odamid-usw2-2.oda.sas.com/SASStudio/main?locale=en_US&z... 1 of 2 8/9/23, 4:21 PM
Code: Hypotesis_test.sas https://odamid-usw2-2.oda.sas.com/SASStudio/main?locale=en_US&z... 2 of 2 8/9/23, 4:21 PM
Uploaded by GrandExploration8149 on coursehero.com