{"id":9518,"date":"2013-12-31T09:00:00","date_gmt":"2013-12-31T09:00:00","guid":{"rendered":"http:\/\/www.smartdatacollective.com\/index.php\/post\/sas-visual-analytics-how-catwoman-influenced-my-data\/"},"modified":"2023-01-25T21:57:56","modified_gmt":"2023-01-25T21:57:56","slug":"sas-visual-analytics-how-catwoman-influenced-my-data","status":"publish","type":"post","link":"https:\/\/www.smartdatacollective.com\/sas-visual-analytics-how-catwoman-influenced-my-data\/","title":{"rendered":"SAS Visual Analytics: How Catwoman Influenced My Data"},"content":{"rendered":"\n<p><a href=\"http:\/\/en.wikipedia.org\/wiki\/Eartha_Kitt\" data-wpel-link=\"external\" rel=\"external noopener noreferrer ugc\">Eartha Kitt<\/a> was the best <a href=\"http:\/\/en.wikipedia.org\/wiki\/Batman_(TV_series)\" data-wpel-link=\"external\" rel=\"external noopener noreferrer ugc\">Cat Woman<\/a>. It\u2019s true \u2013 her voice and diction was what made her so purr-fect for the role. When I was younger I would watch the Batman reruns (POW!) and then try to walk and talk like Eartha. &nbsp;\u201dHow can BatGirl be the best anything when CatWoman is around??\u201d [Check out CatWoman in action <a href=\"https:\/\/www.youtube.com\/watch?v=zXrLJEN0jAQ\" data-wpel-link=\"external\" rel=\"external noopener noreferrer ugc\">here<\/a>!]<\/p>\n\n\n\n<p>You\u2019re probably wondering what that statement has to do with SAS or why I would mention it at all.&nbsp;Last week I was raving about how wonderful it is to use formats with SAS Visual Analytics to solve all your problems and pretty much end all suffering in the world (well, reporting world). &nbsp;But here\u2019s a tip for working with dressed up &nbsp;data items.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A Costume Does Not a Superhero Make<\/h2>\n\n\n\n<p>A format is a way to change how your data appears in a chart or table. &nbsp;You can think of a format like a costume. For instance, even if I had a Cat Woman costume, it would not suddenly empower me with any special powers other than looking similar to her. You wouldn\u2019t find me thinking I had new agile jumping abilities or for that matter deciding to embark upon a criminal enterprise with my new friend the Joker. So the costume would make me look different, but inside I\u2019m still just a geeky SAS programmer.<\/p>\n\n\n\n<p>Think of a format the same way (this is an important concept litter mates!) &nbsp;Your underlying data does not change because you changed the format. For instance, <a href=\"http:\/\/bi-notes.com\/2013\/12\/sas-visual-analytics-date-item-formats\/\" data-wpel-link=\"external\" rel=\"external noopener noreferrer ugc\">using the same example from last week,<\/a> here is my data.&nbsp;The data item,&nbsp;<strong>Arrival Date (Original)<\/strong>, is the true value; it shows the calls per minute. &nbsp;There were several ways to change the data item so it could appear as more than one superhero (or date value). &nbsp;Actually I guess CatWoman was super villain not a hero.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Has the Joker Been in My Report?<\/h2>\n\n\n\n<p>Let\u2019s say that we want to create an \u201cAverage Actions Per Hour\u201d data item to plot in a chart similar to this one. &nbsp;The simplest thing to do is duplicate the Actions (Total) measure and change it\u2019s aggregation from Sum to Average. &nbsp;That\u2019s what I did in the following graphic. But when I double-checked my math on the averages \u2026 it was not what I expected.<\/p>\n\n\n\n<p>My expectation was that 19 actions divided by 3 days would be 6.3 not 3.8. &nbsp;Eeek \u2026 what happened? I doubled checked and the SUM is correct \u2013 there were a total of 19 calls. &nbsp;The average is wrong \u2026 but why?&nbsp;Let\u2019s start by looking at the raw data and then removing some assumptions. &nbsp;My first assumption was that because the X-axis had the actions plotted by Hour that the Actions (Averaged) data item would know what to do. &nbsp;Turns out it does know what to do \u2026 but just not the way I was thinking.<\/p>\n\n\n\n<p>Remember when I said the costume didn\u2019t make me Cat Woman \u2013 well the hour format did change the underlying data in this instance either. &nbsp;Instead of totaling the actions (19) and then dividing by the number of days (3) it divided by the number of values. &nbsp;In this case \u2013 there were 5 values contributing to the end result. &nbsp;SAS Visual Analytics didn\u2019t sum by hour \u2013 instead it did it by minute.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Geez \u2013 What is SAS Visual Analytics Doing?<\/h2>\n\n\n\n<p>Ok \u2013 now we know what we don\u2019t want and how we inadvertently introduced errors into the reporting process. [Another &nbsp;failed example<a href=\"http:\/\/bi-notes.com\/2013\/10\/data-visualization-avoid-epic-fail\/\" data-wpel-link=\"external\" rel=\"external noopener noreferrer ugc\"> here<\/a>.] Seems like we just need to aggregate to the hour level and then it should understand.&nbsp;As we went through last week, create a new calculated item. &nbsp;Since I want the data to be a aggregated to the hour, I need to remove the minutes and seconds from the data item. &nbsp;Using the DateTimeFromDateHMS function, I rebuilt the data item to be at the hour level. &nbsp;The entire trick is really when the 0s are used for the minute and second.<\/p>\n\n\n\n<p>Then I changed the format to Time showing only the hour. &nbsp;My result is below. &nbsp;SAS VA is still using the count of variables as the denominator for the average. &nbsp;So the other values are not having any influence on the calculation. As <a href=\"http:\/\/www.life123.com\/arts-culture\/superheroes\/batman\/funny-batman-and-robin-phrases.shtml\" data-wpel-link=\"external\" rel=\"external noopener noreferrer ugc\">Robin would say<\/a>, \u201cThe batcomputer is none too frisky today, Batman!!\u201d<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Turn off the Bat Signal \u2026 I\u2019ve Got it!<\/h2>\n\n\n\n<p>Tell commissioner Gordon we\u2019ve figure it out \u2013 no <a href=\"http:\/\/en.wikipedia.org\/wiki\/Bat-Signal\" data-wpel-link=\"external\" rel=\"external noopener noreferrer ugc\">Bat Signal <\/a>required. We have to let the calculation know how we want it calculated. So let\u2019s build a new aggregation for our measure.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a New Aggregated Measure.<\/li>\n\n\n\n<li>Use a formula similar to the one below. &nbsp;It\u2019s just sum of actions divided by distinct count of arrival days.Update the chart to use your new measure.<\/li>\n<\/ol>\n\n\n\n<p>Now let\u2019s look at these results next to our original so we can compare how the chart changes. I added a date range slider so the users can determine how to explore the data.&nbsp;Here\u2019s a <a href=\"https:\/\/www.youtube.com\/watch?v=pHurRn3ivlk\" target=\"_blank\" rel=\"noreferrer noopener external ugc\" data-wpel-link=\"external\">video<\/a> I made to show how the date range slider works for this example. In the video you can see how the new measure handles the distinct number of days.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Oh What Purr-fection!<\/h2>\n\n\n\n<p>It\u2019s like many things \u2013 when you let the machine do everything it sometimes doesn\u2019t make the choice you expect or intent. &nbsp;Two lessons from this post \u2013 how to create an aggregate and don\u2019t forget to double-check the math.<\/p>\n\n\n\n<p>Don\u2019t forget to check out the <a href=\"https:\/\/www.youtube.com\/watch?v=pHurRn3ivlk\" data-wpel-link=\"external\" rel=\"external noopener noreferrer ugc\">video<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Eartha Kitt was the best Cat Woman. It\u2019s true \u2013 her voice and diction was what made her so purr-fect for the role. When I was younger I would watch the Batman reruns (POW!) and then try to walk and talk like Eartha. &nbsp;\u201dHow can BatGirl be the best anything when CatWoman is around??\u201d [Check [&hellip;]<\/p>\n","protected":false},"author":237,"featured_media":304237,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"none","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":""},"categories":[15,48],"tags":[215],"class_list":{"0":"post-9518","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-analytics","8":"category-big-data","9":"tag-sas"},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.smartdatacollective.com\/wp-json\/wp\/v2\/posts\/9518","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.smartdatacollective.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.smartdatacollective.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.smartdatacollective.com\/wp-json\/wp\/v2\/users\/237"}],"replies":[{"embeddable":true,"href":"https:\/\/www.smartdatacollective.com\/wp-json\/wp\/v2\/comments?post=9518"}],"version-history":[{"count":1,"href":"https:\/\/www.smartdatacollective.com\/wp-json\/wp\/v2\/posts\/9518\/revisions"}],"predecessor-version":[{"id":310490,"href":"https:\/\/www.smartdatacollective.com\/wp-json\/wp\/v2\/posts\/9518\/revisions\/310490"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.smartdatacollective.com\/wp-json\/wp\/v2\/media\/304237"}],"wp:attachment":[{"href":"https:\/\/www.smartdatacollective.com\/wp-json\/wp\/v2\/media?parent=9518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.smartdatacollective.com\/wp-json\/wp\/v2\/categories?post=9518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.smartdatacollective.com\/wp-json\/wp\/v2\/tags?post=9518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}