{"id":2261,"date":"2012-03-29T19:18:50","date_gmt":"2012-03-30T00:18:50","guid":{"rendered":"http:\/\/www.thejuliagroup.com\/blog\/?p=2261"},"modified":"2012-03-29T20:14:58","modified_gmt":"2012-03-30T01:14:58","slug":"sas-eg-weighted-bar-chart-to-answer-question-on-race-marriage","status":"publish","type":"post","link":"https:\/\/www.thejuliagroup.com\/blog\/sas-eg-weighted-bar-chart-to-answer-question-on-race-marriage\/","title":{"rendered":"SAS EG Weighted Bar Chart to Answer Question on Race &#038; Marriage"},"content":{"rendered":"<p>Not quite three weeks ago, <a href=\"http:\/\/www.thejuliagroup.com\/blog\/?p=2177\">I wrote about how to do a table analysis using SAS Enterprise Guide<\/a> to answer the pressing question of whether men are more or less likely to marry women with more education. I was going to follow up with an explanation of how to get a weighted bar chart.\u00a0Explanation of why it took so long for those of you with intense interest in my personal life follows. For those who don&#8217;t care, said explanation is shaded so you can easily recognize and skip right to the weighted bar chart thing.<\/p>\n<div><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-medium wp-image-2262\" title=\"paperwork\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/paperwork-300x183.jpg\" alt=\"Papers\" width=\"300\" height=\"183\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/paperwork-300x183.jpg 300w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/paperwork.jpg 620w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/div>\n<blockquote><p>A few things interfered &#8211; not having in-flight wi-fi on the plane home, The Spoiled One getting accepted to Notre Dame Academy, receiving a new grant award, a requirement to file taxes in four (!) states. For a while, every surface in my office looked something like this.<\/p>\n<p>I don&#8217;t believe any of the rest of you have to fill out any forms for the rest of the month because I have single-handedly completed the March quota for all of America. Oh, yeah, and I was behind to begin with because of that one daughter winning a world title and other daughter having a baby within the same two weeks thing.<\/p>\n<p>There were also clients who wanted me to do work for actual money.<\/p>\n<p>That, and I ran out of cognac.<\/p><\/blockquote>\n<p><strong>How to do a weighted bar chart using SAS Enterprise Guide<\/strong><\/p>\n<p>I wanted to do a bar chart, using the weights from the American Community Survey, and graph the percentage of African-American women married at each level of education, that is, within the bars. The question we wanted to answer was, &#8220;Does a woman&#8217;s odds of being married go up, down \u00a0or stay the same as she becomes more educated?&#8221; Here it is, for you impatient types. The answer is, the percentage of women who are married is greater the higher the level of education. Her odds go up.<\/p>\n<div>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchartdone.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-2264 aligncenter\" title=\"barchartdone\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchartdone-300x225.jpg\" alt=\"Chart of marital status by education\" width=\"300\" height=\"225\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchartdone-300x225.jpg 300w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchartdone.jpg 640w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<\/div>\n<p style=\"text-align: center;\"><strong>1. Get the Data<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/?p=2177\">The first step, I did previously (you should have been paying attention). I created a table of marital status by educational attainment using the TABLE ANALYSIS task in SAS ENTERPRISE GUIDE. <\/a>Notice in that task I clicked on the tab CELL STATISTICS and clicked the box next to <strong>Include percentages in the data set<\/strong>.<\/p>\n<div><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/tableanalysis5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2183\" title=\"tableanalysis5\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/tableanalysis5.png\" alt=\"Cell Statistics Window\" width=\"371\" height=\"343\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/tableanalysis5.png 371w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/tableanalysis5-300x277.png 300w\" sizes=\"auto, (max-width: 371px) 100vw, 371px\" \/><\/a><\/div>\n<p>Also, I clicked on the tab for CELL STAT RESULTS and clicked the button next to the table I wanted under <strong>Select tables for all cell statistics.<\/strong><\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/tableanalysisCellStat.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2184\" title=\"tableanalysisCellStat\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/tableanalysisCellStat-300x129.png\" alt=\"Cell Stat results window\" width=\"300\" height=\"129\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/tableanalysisCellStat-300x129.png 300w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/tableanalysisCellStat.png 650w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>When the table analysis is run, it will create a data set that includes the statistics I specified.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>2. Use the GRAPH task to create a bar chart<\/strong><\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart11.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2267\" title=\"barchart1\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart11.png\" alt=\"bar chart window\" width=\"345\" height=\"142\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart11.png 345w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart11-300x123.png 300w\" sizes=\"auto, (max-width: 345px) 100vw, 345px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>I. Go to TASKS &gt; GRAPH and then select BAR CHART<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2268 clearfix\" title=\"barchart2\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart2-300x147.png\" alt=\"Select the type of bar chart\" width=\"300\" height=\"147\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart2-300x147.png 300w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart2.png 617w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p style=\"text-align: justify;\">II. The window pops up with BAR CHART TAB highlighted (top of left window pane). Select Vertical Colored Bar because it is pretty.<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2269\" title=\"barchart3\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart3-300x165.png\" alt=\"Data window\" width=\"300\" height=\"165\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart3-300x165.png 300w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart3.png 734w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>III. Click on the DATA tab. Click on the <strong>Edit\u00a0<\/strong>button (top right of the screen).<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2270\" title=\"barchart4\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart4-300x162.png\" alt=\"Select filter\" width=\"300\" height=\"162\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart4-300x162.png 300w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart4.png 648w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>IV. I only wanted to use the people who were married. My data source is already selected. By default it is the last data set I created which, remember, is the statistics from the TABLE ANALYSIS task. I am going to pull down the first box to the variable I want to filter on &#8211; <strong>married<\/strong>\u00a0&#8211; then pull down the second box to what kind of filter I want &#8211; <strong>equals to &#8211; <\/strong>then, in the third box, type what I want it to be equal to &#8211; 1. \u00a0Click OK (bottom right of the screen).<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2271\" title=\"barchart5\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart5-300x143.png\" alt=\"Select data\" width=\"300\" height=\"143\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart5-300x143.png 300w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart5.png 716w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>V. Drag <strong>education <\/strong>under Columns to chart. \u00a0Drag PCT_ROW under Sum of. This will chart each category of education. The Y value will be the sum of the values in the PCT_ROW variable. What exactly is the PCT_ROW variable anyway?<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/blogeducationtable1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2263\" title=\"blogeducationtable\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/blogeducationtable1-300x197.png\" alt=\"Table of education statistics\" width=\"300\" height=\"197\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/blogeducationtable1-300x197.png 300w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/blogeducationtable1.png 768w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>in the table above, which is the output from our TABLE ANALYSIS task (remember that?) the row percent is the highlighted number. Since in Step III, we selected out only those who were married, we will have, for example, 32.87 as our Sum of value for those with less than a high school education.<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2272\" title=\"barchart6\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart6-300x156.png\" alt=\"Advanced tab\" width=\"300\" height=\"156\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart6-300x156.png 300w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart6.png 747w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>VI. Click on the ADVANCED tab in the left window pane. That is near the bottom. Statistic used to calculate bar has SUM selected. That&#8217;s fine. Leave it. On the bottom right, click the box next to Specify one statistical value to show for bars. Sum is already selected.<\/p>\n<p>Guess what? Since you only have one number for each category, it doesn&#8217;t really matter whether you select sum or average. In either case, it is whatever the value is for that category, like 32.87.<\/p>\n<p><a href=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2275\" title=\"barchart7\" src=\"http:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart7-300x270.png\" alt=\"Titles for bar chart\" width=\"300\" height=\"270\" srcset=\"https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart7-300x270.png 300w, https:\/\/www.thejuliagroup.com\/blog\/wp-content\/uploads\/2012\/03\/barchart7.png 525w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>VII. (Optional: If you want some titles, like &#8220;Hey, look at my bar chart!&#8221; and\/or a Footnote, click on the TITLES tab, unclick the button next to Use default text and type whatever you want in the box under it.) Click RUN.<\/p>\n<p>And that, my dear, is how you use SAS Enterprise Guide to do a weighted bar chart for a sub-group of the population.<\/p>\n<p>Your education is now complete.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Not quite three weeks ago, I wrote about how to do a table analysis using SAS Enterprise Guide to answer the pressing question of whether men are more or less likely to marry women with more education. I was going to follow up with an explanation of how to get a weighted bar chart.\u00a0Explanation of&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[],"class_list":["post-2261","post","type-post","status-publish","format-standard","hentry","category-software"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/2261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/comments?post=2261"}],"version-history":[{"count":13,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/2261\/revisions"}],"predecessor-version":[{"id":2277,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/posts\/2261\/revisions\/2277"}],"wp:attachment":[{"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/media?parent=2261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/categories?post=2261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thejuliagroup.com\/blog\/wp-json\/wp\/v2\/tags?post=2261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}