ࡱ> 9;8G =&bjbjَ ^],$d <  $      <` -Z SAS Procedures for Common Statistical Analyses Contents: Introduction/Data Set Up Describing Quantitative Variables Describing Qualitative Variables Two-Sample Tests (Independent Samples) Completely Randomized Design (1-Way ANOVA) Randomized Block Design 2-Factor ANOVA Chi-Square Tests Linear Regression Correlation Generalized Linear Models Logistic Regression Poisson Regression Negative Binomial Regression Introduction/Data Set-Up For all descriptions, we will have datasets where each line represents an individual case, and there are 3 quantitative variables: X, Y, Z measured; and 2 qualtative variables: A, B given, unless otherwise noted. DATA ONE; INPUT X Y Z A B; CARDS; Data Here ; RUN; NOTE: All procedures can be done separately for all levels of one or more factors, and specifically for only cases that meet some criteria. Analysis Conducted separately for all levels of Factor A: Data step RUN; PROC SORT; BY A; RUN; PROC PROCNAME; BY A; Other PROC Statements RUN; Analysis Conducted only on cases where (say) A=1: Data step RUN; PROC PROCNAME; WHERE A=1; Other PROC Statements RUN; Describing Quantitative Variables Dataset contains 3 quantitative variables: X,Y,Z 2 qualitative Factors: A,B Basic Statistics: PROC MEANS Default: Mean, Standard Deviation, Minimum, Maximum For all cases: PROC MEANS; VAR X Y Z; RUN; For cases separately by Factor A: PROC MEANS; CLASS A; VAR X Y Z; RUN; For cases separately by combinations of Factors A & B: PROC MEANS; CLASS A B; VAR X Y Z; RUN; Full-blown Summary: PROC UNIVARIATE Default: Moments, SS, CV, SEM, Median, IQR, Tests for Location (m=0: t-test, Median=0: Sign, Signed-Rank tests), Quantiles, Extreme Observations PROC UNIVARIATE; VAR X Y Z; RUN; Describing Qualitative Variables Note: Dataset need not contain quantitive variables X, Y, Z; but does contain qualitative responses A and B. Frequency Tabulation for a Single Qualitive Response (A): PROC FREQ; TABLES A; RUN; Frequency Cross-Tabulation for Pair of Qualitive Responses (A,B): PROC FREQ; TABLES A*B; RUN; NOTE: In many instances you may wish to re-produce and further analyze data previously published in a contingency table. Then each case is a cell in the table, and you will include a count for each cell. DATA ONE; INPUT A B NUMCASE; CARDS; 1 1 25 1 2 32 2 1 17 2 2 42 ; RUN; PROC FREQ; TABLES A*B; WEIGHT NUMCASE; RUN; 2-Sample tests (Independent Samples) For this case, assume Factor A has 2 levels, and X is our response variable. TTEST Procedure: H0: m1-m2 = 0 versus HA: m1-m2 ( 0 The procedure will conduct the t-test based on the assumptions of equal and unequal variances, as well as the F-test for equal variances to guide you to which analysis to use. PROC TTEST; CLASS A; VAR X; RUN; NPAR1WAY Procedure: H0: M1-M2 = 0 versus HA: M1-M2 ( 0 PROC NPAR1WAY WILCOXON; CLASS A; VAR X; RUN; Completely Randomized Design (1-Way ANOVA) Statistical Model: Y = m + ti + eij = mi + eij i=1,& ,a j=1,& ,ni Let Factor A represent the treatment factor and Y be the response variable. The dataset AOVOUT will contain the original dataset and residuals (with variable name E). ANOVA F-test, Levene s Test for Equal Variance and Bonferroni/Tukey Comparisons PROC GLM; CLASS A; MODEL Y = A; MEANS A / BON TUKEY HOVTEST; OUTPUT OUT=AOVOUT R=E; RUN; Kruskal-Wallis H-Test (Nonparametric) PROC NPAR1WAY WILCOXON; CLASS A; VAR Y; RUN; Randomized Block Design Statistical Model: Y = m + ti + bj + eij = mi +bj + eij i=1,& ,a j=1,& ,b Let A represent the treatment factor, B represent the blocking factor, and Y be the response variable. The dataset AOVOUT will contain the original dataset and residuals (with variable name E). ANOVA F-test and Bonferroni/Tukey Comparisons PROC GLM; CLASS A B; MODEL Y = A B; MEANS A / BON TUKEY; OUTPUT OUT=AOVOUT R=E; RUN; Friedmans Test (Nonparametric) PROC FREQ; TABLES B*A*Y / CMH2 SCORES=RANK NOPRINT; RUN; Statistic and P-Value are printed by Row Mean Scores Differ 2-Factor ANOVA Statistical Model: Y = m + ai + bj +(ab)ij + eijk i=1,& ,a j=1,& ,b k=1,& ,n The dataset AOVOUT will contain the original dataset and residuals (with variable name E). Additive Model  No Interaction PROC GLM; CLASS A B; MODEL Y = A B; MEANS A B / BON TUKEY; OUTPUT OUT=AOVOUT R=E; RUN; Model With Interaction PROC GLM; CLASS A B; MODEL Y = A B A*B; MEANS A B / BON TUKEY; OUTPUT OUT=AOVOUT R=E; RUN; Chi-Square Test Cases are classified on two qualitative variables: A and B Want to test whether the classifications are independent (or that the conditional distribution of variable B is the same for every level of A). PROC FREQ; TABLES A*B / CHISQ EXPECTED; RUN; When measures of association (and tests of significance) are desired instead of the Chi-Square test, use: PROC FREQ; TABLES A*B / MEASURES; RUN; Linear Regression Simple Linear Regression Statistical Model: Yi = b0 + b1Xi + ei i=1,& ,n The dataset REGOUT will contain the original dataset and residuals (with variable name E). PROC REG; MODEL Y = X; OUTPUT OUT=REGOUT R=E; RUN; Multiple Linear Regression (Dataset contains variables X1,& ,Xk) Statistical Model: Yi = b0 + b1X1i +& + bkXki + ei i=1,& ,n PROC REG; MODEL Y = X1 X2 & Xk; OUTPUT OUT=REGOUT R=E; RUN; Correlation Data: Variables Y1,& ,Yk Pairwise Bivariate Correlations PROC CORR; VAR Y1 Yk; RUN; Partial Correlation between Y and Z, Controlling for X PROC CORR; VAR Y Z; PARTIAL X; RUN: Generalized Linear Models Logistic Regression Statistical Model: Y is a binary outcome:  EMBED Equation.3  PROC GENMOD; MODEL Y = X / DIST=BIN LINK=LOGIT; RUN; Poisson Regression Statistical Model: Y is a count outcome: Yi ~ Poisson(li) log(li) = b0 + b1XI E(Yi) = (li) V(Yi) = li PROC GENMOD; MODEL Y = X / DIST=POI LINK=LOG; RUN; Negative Binomial Regression Statistical Model: Y is a count outcome: Yi ~ NB(li,k) log(li) = b0 + b1Xi E(Yi) = (li) V(Yi) = li + (li2/k) PROC GENMOD; MODEL Y = X / DIST=NB LINK=LOG; RUN; /1<YZ&08E[_`! " 1 L M N p 0 R Y Z  ߸ CJOJQJ>*5CJOJQJ5CJ OJQJ 5>*CJ$CJ 5>*CJ,5CJOJQJ5CJOJQJ5CJ 5>*CJ(5CJ 5>*CJ 5CJ,D/01;<Uw#5C^r & Fx h & Fxx$/01;<Uw#5C^rYZ&+:ľab                                     2YZ&+:x$ & Fx:E[`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:2$W}eA .hTacJs71\ # -jְuwzrVUեxcVA(^Bg8v2 1o/|9Ec^ ?Z,5kjh(DC)nA<2Kt3?uzޓgml* )۱,4m;^\N(_`~cSV뎎l_~U;{6 t8r3"'Еksv֤_\B}팤9܈;Mׂ;_sV{OMl>.wEuϗ?qv WF _/.!rso?{*m맙  !"#$%&'()*+,-./1234567:=>J?@BCDEFGHIRoot Entry  FDjXZ<Data 0WordDocument ^ObjectPool ZZ_1220767353FZ/ZOle CompObjfObjInfo  FMicrosoft Equation 3.0 DS Equation Equation.39qtxItI  i =P(Y i =1)=e  0 + 1 X i 1+e  0 + 1 X iEquation Native ,1TableASummaryInformation( DocumentSummaryInformation8 i=1,...,n Oh+'0  $0 L X dpx/SAS Procedures for Common Statistical Analyses0AS  Larry Winners farr Normal.dotr Larry Winners f26rMicrosoft Word 8.0C@@nö@J _PID_GUIDAN{5E580519-4C6B-11DB-9EAF-00045A9E307E}  FMicrosoft Word Document MSWordDocWord.Document.89q [$@$NormalmH :@: Heading 1 $x@& 5>*CJ$8@8 Heading 2 $x@&5CJ @@@ Heading 3 $x@&5CJOJQJ:@: Heading 4 $x@& 5>*CJ <@< Heading 5$x@&5CJ >@> Heading 6$x@& 5>*CJ <A@<Default Paragraph Font2B@2 Body Text$5CJ,6P@6 Body Text 2x5CJ 8Y8 Document Map-D OJQJDC@"DBody Text Indent x5CJ ^ %=& $*-: B<0N9"r%=&!#&'),.: Aw`9"=&"%(+: Larry Winner1\\SAMBA\WINNER\public_html\computing\sas\sas1.doc Larry Winner1\\SAMBA\WINNER\public_html\computing\sas\sas1.doc Larry Winner1\\SAMBA\WINNER\public_html\computing\sas\sas1.doc Larry Winner1\\SAMBA\WINNER\public_html\computing\sas\sas1.doc Larry Winner1\\SAMBA\WINNER\public_html\computing\sas\sas1.doc Larry Winner1\\SAMBA\WINNER\public_html\computing\sas\sas1.doc Larry Winner1\\SAMBA\WINNER\public_html\computing\sas\sas1.doc Larry Winner1\\SAMBA\WINNER\public_html\computing\sas\sas1.doc Larry Winner1\\SAMBA\WINNER\public_html\computing\sas\sas1.doc Larry Winner-C:\windows\TEMP\AutoRecovery save of sas1.asd 55,9%%VFx#( w 4(;j DTʒ%hWڳvcl4SC n*CJOJQJo(hh. hhOJQJo( _t55cl#(";vj DT9%%w 4C n%hW @ ddP@P P@PP @PP(@PP0@PP8@PP PD@P$PL@GTimes New Roman5Symbol3& ArialO&Albertus Extra Bold5& :Tahoma"1hʩ&[˪fjj{ )!0d.SAS Procedures for Common Statistical Analyses Larry Winner Larry WinnerCompObjj