

{"id":12485,"date":"2018-04-06T06:07:05","date_gmt":"2018-04-06T06:07:05","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=12485"},"modified":"2021-05-09T13:16:21","modified_gmt":"2021-05-09T07:46:21","slug":"sas-chi-square-test","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/","title":{"rendered":"SAS Chi-Square Test &#8211; SAS PROC FREQ"},"content":{"rendered":"<p>We looked at<strong> SAS t-test<\/strong>, <strong>correlation<\/strong> and <strong>regression<\/strong>, <strong>ANOVA<\/strong> in the previous tutorials, today we will be looking at another process called SAS Chi-Square test, how can we create and a two-way chi-square test in SAS Programming Language.<\/p>\n<p>Moreover, we will discuss some SAS Chi-Square Test examples to under this concept better.<\/p>\n<p>So, let&#8217;s\u00a0start with SAS Chi-Square Test and SAS Proc Freq.<\/p>\n<h2>What is Chi-Square Test in SAS<\/h2>\n<p>SAS\u00a0Chi-Square test\u00a0of Independence is used to determine if there is a significant relationship between two categorical variables.<\/p>\n<p>Chi-Square Testing independence determines whether two or more observations across two populations are dependent on each other (that is, whether one variable helps to estimate the other).<\/p>\n<p>Testing for goodness of fit determines if an observed frequency distribution matches a theoretical frequency distribution. In both cases, the equation to calculate the chi-square statistic is where O equals the observed frequency and\u00a0<em>E<\/em>\u00a0the expected frequency.<\/p>\n<h2>SAS PROC FREQ Procedure<\/h2>\n<p>We saw the use of PROC FREQ, to create frequency distribution tables, but it can also be used with a CHISQ option to create SAS chi-square test.<\/p>\n<p><strong>Syntax-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">PROC FREQ DATA = dataset;\r\nTABLES variables \/CHISQ TESTP=(percentage values);<\/pre>\n<p>Here Percentage Values\u00a0in the TESTP statement denotes the percentage of levels of the <strong>variable<\/strong>.<\/p>\n<h2>One Way Chi-Square Test<\/h2>\n<p>In the below SAS Chi-square test example, we consider a SAS chi-square test on the variable named origin in the <strong>data set<\/strong> SASHELP.CARS. This variable has three levels and we assign a percentage to each level.<\/p>\n<p><strong>SAS Chi-Square Test\u00a0Example-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">proc freq data = sashelp.cars;\r\ntables origin \/chisq\r\ntestp=(0.35 0.40 0.25);\r\nrun;<\/pre>\n<div id=\"attachment_12492\" style=\"width: 553px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/chi-square-test1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-12492\" class=\"wp-image-12492 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/chi-square-test1.png\" alt=\"SAS Chi Square Test\" width=\"543\" height=\"316\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/chi-square-test1.png 543w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/chi-square-test1-150x87.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/chi-square-test1-300x175.png 300w\" sizes=\"auto, (max-width: 543px) 100vw, 543px\" \/><\/a><p id=\"caption-attachment-12492\" class=\"wp-caption-text\">SAS Chi Square Test<\/p><\/div>\n<p>&nbsp;<\/p>\n<div id=\"attachment_12493\" style=\"width: 922px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/chi-square-out2.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-12493\" class=\"wp-image-12493 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/chi-square-out2.jpg\" alt=\"SAS Chi Square Test\" width=\"912\" height=\"733\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/chi-square-out2.jpg 912w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/chi-square-out2-150x121.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/chi-square-out2-300x241.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/chi-square-out2-768x617.jpg 768w\" sizes=\"auto, (max-width: 912px) 100vw, 912px\" \/><\/a><p id=\"caption-attachment-12493\" class=\"wp-caption-text\">One Way Chi-Square Test Output<\/p><\/div>\n<h2>Two Way Chi-Square Test<\/h2>\n<p>In this, two variables are used instead of one and the SAS chi-square test is applied on both of them.<\/p>\n<p><strong>Example-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">proc freq data = sashelp.cars;\r\ntables origin*drivetrain \/chisq ;\r\nrun;<\/pre>\n<div id=\"attachment_12494\" style=\"width: 583px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/two-way-chi-test.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-12494\" class=\"wp-image-12494 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/two-way-chi-test.png\" alt=\"SAS Chi Square Test\" width=\"573\" height=\"762\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/two-way-chi-test.png 573w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/two-way-chi-test-113x150.png 113w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/two-way-chi-test-226x300.png 226w\" sizes=\"auto, (max-width: 573px) 100vw, 573px\" \/><\/a><p id=\"caption-attachment-12494\" class=\"wp-caption-text\">Two Way Chi-Square\u00a0Test Example with Output<\/p><\/div>\n<p>This was all about Chi-Square Test Tutorial. Hope you like our explanation of one way and two-way chi-square analysis in SAS Programming Language.<\/p>\n<h2>Conclusion<\/h2>\n<p>Hope you all understood what is a chi-square test and how can we create it in SAS. We also saw a two-way chi-square test in SAS. In conclusion, we saw some SAS Chi-square test examples.<\/p>\n<p>Furthermore, if you have any query feel free to ask in a comment section.\u00a0and stay tuned to learn more interesting things in SAS.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We looked at SAS t-test, correlation and regression, ANOVA in the previous tutorials, today we will be looking at another process called SAS Chi-Square test, how can we create and a two-way chi-square test&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":12491,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[59],"tags":[2500,2501,2502,3081,11957,12148,15925],"class_list":["post-12485","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sas","tag-chi-square-examples","tag-chi-square-test-examples","tag-chi-square-test-in-sas","tag-create-sas-chi-square-test","tag-sas-chi-square-test","tag-sas-proc-freq","tag-what-is-sas-chi-square-test"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SAS Chi-Square Test - SAS PROC FREQ - DataFlair<\/title>\n<meta name=\"description\" content=\"Chi-square test tutorial- What is SAS Chi-square test, How to run chi-square analysis,SAS Chi-square test example, proc Freq,Two Way &amp; One Way SAS Chi-Square Test\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SAS Chi-Square Test - SAS PROC FREQ - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Chi-square test tutorial- What is SAS Chi-square test, How to run chi-square analysis,SAS Chi-square test example, proc Freq,Two Way &amp; One Way SAS Chi-Square Test\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-06T06:07:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-09T07:46:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/SAS-Chi-square-test-01.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SAS Chi-Square Test - SAS PROC FREQ - DataFlair","description":"Chi-square test tutorial- What is SAS Chi-square test, How to run chi-square analysis,SAS Chi-square test example, proc Freq,Two Way & One Way SAS Chi-Square Test","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/","og_locale":"en_US","og_type":"article","og_title":"SAS Chi-Square Test - SAS PROC FREQ - DataFlair","og_description":"Chi-square test tutorial- What is SAS Chi-square test, How to run chi-square analysis,SAS Chi-square test example, proc Freq,Two Way & One Way SAS Chi-Square Test","og_url":"https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-04-06T06:07:05+00:00","article_modified_time":"2021-05-09T07:46:21+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/SAS-Chi-square-test-01.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89"},"headline":"SAS Chi-Square Test &#8211; SAS PROC FREQ","datePublished":"2018-04-06T06:07:05+00:00","dateModified":"2021-05-09T07:46:21+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/"},"wordCount":399,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/SAS-Chi-square-test-01.jpg","keywords":["Chi-Square examples","Chi-Square test examples","Chi-Square Test in SAS","create SAS chi-square test","SAS Chi-Square Test","SAS PROC FREQ","What is SAS Chi-Square Test"],"articleSection":["SAS Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/","url":"https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/","name":"SAS Chi-Square Test - SAS PROC FREQ - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/SAS-Chi-square-test-01.jpg","datePublished":"2018-04-06T06:07:05+00:00","dateModified":"2021-05-09T07:46:21+00:00","description":"Chi-square test tutorial- What is SAS Chi-square test, How to run chi-square analysis,SAS Chi-square test example, proc Freq,Two Way & One Way SAS Chi-Square Test","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/SAS-Chi-square-test-01.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/04\/SAS-Chi-square-test-01.jpg","width":1200,"height":628,"caption":"SAS Chi Square Test"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/sas-chi-square-test\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"garbage collection algorithm in data structure","item":"https:\/\/data-flair.training\/blogs\/tag\/garbage-collection-algorithm-in-data-structure\/"},{"@type":"ListItem","position":3,"name":"SAS Chi-Square Test &#8211; SAS PROC FREQ"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"The DataFlair Team provides industry-driven content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our expert educators focus on delivering value-packed, easy-to-follow resources for tech enthusiasts and professionals.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam2\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/12485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=12485"}],"version-history":[{"count":5,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/12485\/revisions"}],"predecessor-version":[{"id":93114,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/12485\/revisions\/93114"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/12491"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=12485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=12485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=12485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}