

{"id":12031,"date":"2018-03-28T09:40:04","date_gmt":"2018-03-28T04:10:04","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=12031"},"modified":"2021-05-09T13:16:37","modified_gmt":"2021-05-09T07:46:37","slug":"sas-histogram-statement","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/sas-histogram-statement\/","title":{"rendered":"SAS Histogram Statement with UNIVARIATE Procedure &amp; Normal Curve"},"content":{"rendered":"<p>The most important aspect of data analysis is a representation of data in the form of graphs and charts. Today we will be looking at how to represent our data in the form of a histogram in SAS Programming Language.<\/p>\n<p>Besides this, we will also be looking at the different functions and parameters that can be added to our SAS histogram to make it easier to understand. We will also study PROC univariate histogram normal curve.<\/p>\n<p>Let&#8217;s start with SAS Histogram Statements.<\/p>\n<h2>What is SAS Histogram?<\/h2>\n<p>In statistics, a histogram is a graphical display of tabulated frequency. SAS histogram differs from a bar chart in that it is the area of the bar that denotes the value, not the height.<\/p>\n<p>Histograms in SAS allow you to explore your data by displaying the distribution of a continuous variable (percentage of a sample) against categories of the value.<\/p>\n<p>You can obtain the shape of the distribution and the data are distributed symmetrically. In SAS, the histograms can be produced using PROC UNIVARIATE, PROC CHART, or PROC GCHART.<strong>\u00a0<\/strong><\/p>\n<h3>SAS UNIVARIATE Procedure<\/h3>\n<p>The syntax of creating a SAS histogram-<\/p>\n<pre class=\"EnlighterJSRAW\">PROC UNIVARIATE DATA = DATASET;\r\nHISTOGRAM variables\u00a0 \/ options;\r\nRUN;<\/pre>\n<p>With the use of SAS Histogram statement in PROC UNIVARIATE, we can have a fast and simple way to review the overall distribution of a quantitative variable in a graphical display.<\/p>\n<p>You can use any number of Histogram statements in SAS after a PROC UNIVARIATE statement. The components of the SAS HISTOGRAM statement are:<\/p>\n<h3>1. Variables<\/h3>\n<p>This is used to create SAS histograms. If you do not specify\u00a0<em>variables<\/em>\u00a0in a VAR statement or in the HISTOGRAM statement, then by default, a histogram is created for each numeric variable in the DATA= data set.<\/p>\n<p>If you use a VAR statement and do not specify any\u00a0<em>v<\/em>ariable<em>s<\/em>\u00a0in the HISTOGRAM statement, then by default, a histogram is created for each variable listed in the VAR statement.<\/p>\n<p>For example, suppose a data set named\u00a0Steel\u00a0contains exactly two numeric variables named\u00a0Length\u00a0and\u00a0Width. The following statements create two histograms, one for\u00a0Length\u00a0and one for\u00a0Width:<\/p>\n<pre class=\"EnlighterJSRAW\">proc univariate data=Steel;\r\n\u00a0\u00a0 histogram;\r\nrun;<\/pre>\n<p>Likewise, the following statements create histograms for\u00a0Length\u00a0and\u00a0Width:<\/p>\n<pre class=\"EnlighterJSRAW\">proc univariate data=Steel;\r\n\u00a0\u00a0 var Length Width;\r\n\u00a0\u00a0 histogram;\r\nrun;<\/pre>\n<p>The following statements create a histogram for\u00a0<em>Length<\/em>\u00a0only:<\/p>\n<pre class=\"EnlighterJSRAW\">proc univariate data=Steel;\r\n\u00a0\u00a0 var Length Width;\r\n\u00a0\u00a0 histogram Length;\r\nrun;<\/pre>\n<h3>2. Options<\/h3>\n<p>It adds features to the histogram. Specify all\u00a0options\u00a0after the slash (\/) in the SAS HISTOGRAM statement.<\/p>\n<p>For example, in the following statements, the NORMAL option displays a fitted normal curve on the histogram, the MIDPOINTS= option specifies midpoints for the histogram, and the CTEXT= option specifies the color of the text:<\/p>\n<pre class=\"EnlighterJSRAW\">proc univariate data=Steel;\r\n\u00a0\u00a0 histogram Length \/ normal\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 midpoints = 5.6 5.8 6.0 6.2 6.4\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ctext\u00a0\u00a0\u00a0\u00a0 = blue;\r\nrun;<\/pre>\n<h3>SAS Histogram with Normal Curve<\/h3>\n<p>Let\u2019s start by creating a simple SAS histogram of the WEIGHT variable. We will use the inbuilt data set sashelp.class:<\/p>\n<pre class=\"EnlighterJSRAW\">TITLE 'Summary of Weight Variable (in pounds)';\r\n\u00a0PROC UNIVARIATE DATA = sashelp.class NOPRINT;\r\nHISTOGRAM weight \/ NORMAL; RUN;<\/pre>\n<p>We can have more than one analysis variable in the SAS Histogram statement. Each variable will have a separate histogram in SAS. NOPRINT option suppresses the summary statistics, the NORMAL option presents a normal curve.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Capture-3.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-12127 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Capture-3.jpg\" alt=\"SAS Histogram with Normal Curve\" width=\"786\" height=\"539\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Capture-3.jpg 786w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Capture-3-150x103.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Capture-3-300x206.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Capture-3-768x527.jpg 768w\" sizes=\"auto, (max-width: 786px) 100vw, 786px\" \/><\/a><\/p>\n<h3>SAS Histogram with Different Customizable Options<\/h3>\n<p>With the SAS histogram statement, different options can be added to the following:<\/p>\n<p>1. We can add the <strong>CFILL<\/strong> option to fill color for the histogram and INSET statement to insert a box of the summary statistics directly in the graph.<\/p>\n<p>2. By default the font of the text in the inset bo inside the graph is <strong>FONT=SIMPLEX<\/strong>.<\/p>\n<p>3. The <strong>MIDPOINTS<\/strong>= option specifies midpoints for the histogram,<\/p>\n<p>4. The <strong>CTEXT<\/strong>= option specifies the color of the text.<\/p>\n<p><strong>Example-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">PROC UNIVARIATE DATA = sashelp.class;\r\nHISTOGRAM weight \/ NORMAL CFILL = ltgray;\r\nINSET N = 'Number of students' MEDIAN (8.2) MEAN (8.2) STD=\u2019Standard Deviation\u2019 (8.3) \/ POSITION = ne;\r\nRUN;<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Capturde.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-12128 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Capturde.jpg\" alt=\"SAS Histogram with Different Customizable Options\" width=\"695\" height=\"555\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Capturde.jpg 695w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Capturde-150x120.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Capturde-300x240.jpg 300w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/a><\/p>\n<p>The above graph shows the SAS histogram with different customizable options<\/p>\n<h2>Summary<\/h2>\n<p>We saw two ways to design SAS histogram, one was a basic one, the other was with different options to suit our requirements. SAS has a repository of text styles, colors, options that can be added to our histogram for better readability. You can go through them in the SAS help directory.<\/p>\n<p>If you have any query feel free to ask in the comment section.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The most important aspect of data analysis is a representation of data in the form of graphs and charts. Today we will be looking at how to represent our data in the form of&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":12042,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[59],"tags":[273,12043,12045,12302,15156,15927],"class_list":["post-12031","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sas","tag-advance-sas-programming","tag-sas-histogram","tag-sas-histogram-with-normal-curve","tag-sas-univariate-procedure","tag-univariate-procedure","tag-what-is-sas-histogram"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SAS Histogram Statement with UNIVARIATE Procedure &amp; Normal Curve - DataFlair<\/title>\n<meta name=\"description\" content=\"SAS Histogram tutorial covers what is Histogram in SAS, SAS Univariate Procedure, SAS Histogram with Normal Curve, SAS Histogram with Customizable Options.\" \/>\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-histogram-statement\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SAS Histogram Statement with UNIVARIATE Procedure &amp; Normal Curve - DataFlair\" \/>\n<meta property=\"og:description\" content=\"SAS Histogram tutorial covers what is Histogram in SAS, SAS Univariate Procedure, SAS Histogram with Normal Curve, SAS Histogram with Customizable Options.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/sas-histogram-statement\/\" \/>\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-03-28T04:10:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-09T07:46:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/SAS-Histogram-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=\"4 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SAS Histogram Statement with UNIVARIATE Procedure &amp; Normal Curve - DataFlair","description":"SAS Histogram tutorial covers what is Histogram in SAS, SAS Univariate Procedure, SAS Histogram with Normal Curve, SAS Histogram with Customizable Options.","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-histogram-statement\/","og_locale":"en_US","og_type":"article","og_title":"SAS Histogram Statement with UNIVARIATE Procedure &amp; Normal Curve - DataFlair","og_description":"SAS Histogram tutorial covers what is Histogram in SAS, SAS Univariate Procedure, SAS Histogram with Normal Curve, SAS Histogram with Customizable Options.","og_url":"https:\/\/data-flair.training\/blogs\/sas-histogram-statement\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-03-28T04:10:04+00:00","article_modified_time":"2021-05-09T07:46:37+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/SAS-Histogram-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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/sas-histogram-statement\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/sas-histogram-statement\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89"},"headline":"SAS Histogram Statement with UNIVARIATE Procedure &amp; Normal Curve","datePublished":"2018-03-28T04:10:04+00:00","dateModified":"2021-05-09T07:46:37+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/sas-histogram-statement\/"},"wordCount":642,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/sas-histogram-statement\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/SAS-Histogram-01.jpg","keywords":["Advance SAS Programming","SAS Histogram","SAS Histogram with Normal Curve","SAS Univariate Procedure","UNIVARIATE Procedure","What is SAS Histogram"],"articleSection":["SAS Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/sas-histogram-statement\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/sas-histogram-statement\/","url":"https:\/\/data-flair.training\/blogs\/sas-histogram-statement\/","name":"SAS Histogram Statement with UNIVARIATE Procedure &amp; Normal Curve - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/sas-histogram-statement\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/sas-histogram-statement\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/SAS-Histogram-01.jpg","datePublished":"2018-03-28T04:10:04+00:00","dateModified":"2021-05-09T07:46:37+00:00","description":"SAS Histogram tutorial covers what is Histogram in SAS, SAS Univariate Procedure, SAS Histogram with Normal Curve, SAS Histogram with Customizable Options.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/sas-histogram-statement\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/sas-histogram-statement\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/sas-histogram-statement\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/SAS-Histogram-01.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/SAS-Histogram-01.jpg","width":1200,"height":628,"caption":"SAS Histogram Statements"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/sas-histogram-statement\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"SAS Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/sas\/"},{"@type":"ListItem","position":3,"name":"SAS Histogram Statement with UNIVARIATE Procedure &amp; Normal Curve"}]},{"@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\/12031","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=12031"}],"version-history":[{"count":7,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/12031\/revisions"}],"predecessor-version":[{"id":93361,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/12031\/revisions\/93361"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/12042"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=12031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=12031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=12031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}