PROC FREQ Statement
Total Page:16
File Type:pdf, Size:1020Kb
SAS/STAT® 13.1 User’s Guide The FREQ Procedure This document is an individual chapter from SAS/STAT® 13.1 User’s Guide. The correct bibliographic citation for the complete manual is as follows: SAS Institute Inc. 2013. SAS/STAT® 13.1 User’s Guide. Cary, NC: SAS Institute Inc. Copyright © 2013, SAS Institute Inc., Cary, NC, USA All rights reserved. Produced in the United States of America. For a hard-copy book: No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, SAS Institute Inc. For a web download or e-book: Your use of this publication shall be governed by the terms established by the vendor at the time you acquire this publication. The scanning, uploading, and distribution of this book via the Internet or any other means without the permission of the publisher is illegal and punishable by law. Please purchase only authorized electronic editions and do not participate in or encourage electronic piracy of copyrighted materials. Your support of others’ rights is appreciated. U.S. Government License Rights; Restricted Rights: The Software and its documentation is commercial computer software developed at private expense and is provided with RESTRICTED RIGHTS to the United States Government. Use, duplication or disclosure of the Software by the United States Government is subject to the license terms of this Agreement pursuant to, as applicable, FAR 12.212, DFAR 227.7202-1(a), DFAR 227.7202-3(a) and DFAR 227.7202-4 and, to the extent required under U.S. federal law, the minimum restricted rights as set out in FAR 52.227-19 (DEC 2007). If FAR 52.227-19 is applicable, this provision serves as notice under clause (c) thereof and no other notice is required to be affixed to the Software or documentation. The Government’s rights in Software and documentation shall be only those set forth in this Agreement. SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513-2414. December 2013 SAS provides a complete selection of books and electronic products to help customers use SAS® software to its fullest potential. For more information about our offerings, visit support.sas.com/bookstore or call 1-800-727-3228. SAS® and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are trademarks of their respective companies. Gain Greater Insight into Your SAS® Software with SAS Books. Discover all that you need on your journey to knowledge and empowerment. support.sas.com/bookstore for additional books and resources. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are trademarks of their respective companies. © 2013 SAS Institute Inc. All rights reserved. S107969US.0613 Chapter 40 The FREQ Procedure Contents Overview: FREQ Procedure.................................. 2622 Getting Started: FREQ Procedure............................... 2624 Frequency Tables and Statistics............................. 2624 Agreement Study..................................... 2631 Syntax: FREQ Procedure.................................... 2634 PROC FREQ Statement................................. 2634 BY Statement ...................................... 2636 EXACT Statement.................................... 2637 OUTPUT Statement................................... 2645 TABLES Statement ................................... 2656 TEST Statement..................................... 2693 WEIGHT Statement................................... 2696 Details: FREQ Procedure.................................... 2697 Inputting Frequency Counts............................... 2697 Grouping with Formats ................................. 2698 Missing Values...................................... 2699 In-Database Computation ................................ 2701 Statistical Computations................................. 2702 Definitions and Notation............................ 2702 Chi-Square Tests and Statistics . 2704 Measures of Association............................ 2709 Binomial Proportion .............................. 2719 Risks and Risk Differences........................... 2725 Common Risk Difference............................ 2736 Odds Ratio and Relative Risks for 2 x 2 Tables . 2737 Cochran-Armitage Test for Trend . 2740 Jonckheere-Terpstra Test............................ 2741 Tests and Measures of Agreement . 2743 Cochran-Mantel-Haenszel Statistics . 2748 Gail-Simon Test for Qualitative Interactions . 2756 Exact Statistics................................. 2757 Computational Resources ................................ 2761 Output Data Sets..................................... 2762 Displayed Output..................................... 2765 ODS Table Names.................................... 2773 ODS Graphics...................................... 2777 2622 F Chapter 40: The FREQ Procedure Examples: FREQ Procedure.................................. 2778 Example 40.1: Output Data Set of Frequencies . 2778 Example 40.2: Frequency Dot Plots........................... 2781 Example 40.3: Chi-Square Goodness-of-Fit Tests . 2784 Example 40.4: Binomial Proportions . 2788 Example 40.5: Analysis of a 2x2 Contingency Table . 2791 Example 40.6: Output Data Set of Chi-Square Statistics . 2794 Example 40.7: Cochran-Mantel-Haenszel Statistics . 2796 Example 40.8: Cochran-Armitage Trend Test . 2798 Example 40.9: Friedman’s Chi-Square Test . 2802 Example 40.10: Cochran’s Q Test............................ 2803 References........................................... 2806 Overview: FREQ Procedure The FREQ procedure produces one-way to n-way frequency and contingency (crosstabulation) tables. For two-way tables, PROC FREQ computes tests and measures of association. For n-way tables, PROC FREQ provides stratified analysis by computing statistics across, as well as within, strata. For one-way frequency tables, PROC FREQ computes goodness-of-fit tests for equal proportions or specified null proportions. For one-way tables, PROC FREQ also provides confidence limits and tests for binomial proportions, including tests for noninferiority and equivalence. For contingency tables, PROC FREQ can compute various statistics to examine the relationships between two classification variables. For some pairs of variables, you might want to examine the existence or strength of any association between the variables. To determine if an association exists, chi-square tests are computed. To estimate the strength of an association, PROC FREQ computes measures of association that tend to be close to zero when there is no association and close to the maximum (or minimum) value when there is perfect association. The statistics for contingency tables include the following: • chi-square tests and measures • measures of association • risks (binomial proportions) and risk differences for 2 2 tables • odds ratios and relative risks for 2 2 tables • tests for trend • tests and measures of agreement • Cochran-Mantel-Haenszel statistics Overview: FREQ Procedure F 2623 PROC FREQ computes asymptotic standard errors, confidence intervals, and tests for measures of association and measures of agreement. Exact p-values and confidence intervals are available for many test statistics and measures. PROC FREQ also performs analyses that adjust for any stratification variables by computing statistics across, as well as within, strata for n-way tables. These statistics include Cochran-Mantel-Haenszel statistics and measures of agreement. In choosing measures of association to use in analyzing a two-way table, you should consider the study design (which indicates whether the row and column variables are dependent or independent), the measurement scale of the variables (nominal, ordinal, or interval), the type of association that each measure is designed to detect, and any assumptions required for valid interpretation of a measure. You should exercise care in selecting measures that are appropriate for your data. Similar comments apply to the choice and interpretation of test statistics. For example, the Mantel-Haenszel chi-square statistic requires an ordinal scale for both variables and is designed to detect a linear association. The Pearson chi-square, on the other hand, is appropriate for all variables and can detect any kind of association, but it is less powerful for detecting a linear association because its power is dispersed over a greater number of degrees of freedom (except for 2 2 tables). For more information about selecting the appropriate statistical analyses, see Agresti(2007) and Stokes, Davis, and Koch(2012). Several SAS procedures produce frequency counts; only PROC FREQ computes chi-square tests for one-way to n-way tables and measures of association and agreement for contingency tables. Other procedures to consider for counting include the TABULATE and UNIVARIATE procedures. When you want to produce contingency tables and tests of association for sample survey data, use PROC SURVEYFREQ. See Chapter 14, “Introduction to Survey Procedures,” for more information. When you want to fit models to categorical data, use a procedure such as CATMOD, GENMOD, GLIMMIX, LOGISTIC, PROBIT, or SURVEYLOGISTIC. See Chapter 8, “Introduction to Categorical