<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Create a bar chart with heights for the percentage of the month total in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/768359#M243719</link>
    <description>This almost works, but there is the same problem I was having. I want all the bars for group 1 to be adjacent to each other (I used the word 'cluster' in the question - maybe that was confusing).</description>
    <pubDate>Fri, 17 Sep 2021 19:42:05 GMT</pubDate>
    <dc:creator>kz_</dc:creator>
    <dc:date>2021-09-17T19:42:05Z</dc:date>
    <item>
      <title>Create a bar chart with heights for the percentage of the month total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767529#M243344</link>
      <description>&lt;P&gt;I want to create a bar chart of data that is similar to that below. The bar chart should&amp;nbsp;&lt;/P&gt;&lt;P&gt;- have a separate plot for each type&amp;nbsp;&lt;/P&gt;&lt;P&gt;- have a cluster for each group, which has two bars (one for each month)&lt;/P&gt;&lt;P&gt;- set the height of the bar for each month as the percentage that that group constitutes of the total for that month.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, in the first plot for "basic" there would be three clusters. The group 1 cluster would have one bar for 2019-01 of height 100% (it constitutes all the data for that month) and one bar of height 50% for 2019-02.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The group 2 cluster would be 0% for both months.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The group 3 cluster would be 0% for 2019-01 and 50% for 2019-02.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I added these percentages in the 4th column, but it obviously doesn't capture the 0% observations. Also the percentages are repeated for each type-group-month, but there should only be one bar for each combination.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obviously, I have way more data (groups, types, months) than this.&lt;/P&gt;&lt;P&gt;(Also I don't know how to write the input for the date since my data are already in SAS - this reads the date in wrong, but I can't figure out why.)&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data noname; &lt;BR /&gt;infile datalines delimiter= ',';&lt;BR /&gt;input type $ group yr_mo YYMMD. percent_of_month_by_type;&lt;BR /&gt;datalines; &lt;BR /&gt;basic, 1, 2019-01, 100%&lt;BR /&gt;basic, 1, 2019-01, 100%&lt;BR /&gt;basic, 1, 2019-02, 50%&lt;BR /&gt;basic, 3, 2019-02, 50% &lt;BR /&gt;normal, 1, 2019-01, 50%&lt;BR /&gt;normal, 2, 2019-01, 50%&lt;BR /&gt;normal, 2, 2019-02, 33%&lt;BR /&gt;normal, 3, 2019-02, 66%&lt;BR /&gt;normal, 3, 2019-02, 66%&lt;BR /&gt;;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 20:26:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767529#M243344</guid>
      <dc:creator>kz_</dc:creator>
      <dc:date>2021-09-13T20:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create a bar chart with heights for the percentage of the month total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767530#M243345</link>
      <description>&lt;P&gt;A nice alternative would be a way to construct a bar chart with user-defined heights for the bars. If you take out the repeated rows above, the height is specified by the percent on the right.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;basic, 1, 2019-01, 100%&lt;BR /&gt;basic, 1, 2019-02, 50%&lt;BR /&gt;basic, 3, 2019-02, 50% &lt;BR /&gt;normal, 1, 2019-01, 50%&lt;BR /&gt;normal, 2, 2019-01, 50%&lt;BR /&gt;normal, 2, 2019-02, 33%&lt;BR /&gt;normal, 3, 2019-02, 66%&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 20:16:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767530#M243345</guid>
      <dc:creator>kz_</dc:creator>
      <dc:date>2021-09-13T20:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create a bar chart with heights for the percentage of the month total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767531#M243346</link>
      <description>If you put in fake values then plot that data wouldn't that be a user defined height?&lt;BR /&gt;How do you want to user define the heights? Is that via  prompt or some file that's provided? Will all data be refreshed or will you expect users to manually enter all data each month?</description>
      <pubDate>Mon, 13 Sep 2021 19:20:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767531#M243346</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-09-13T19:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create a bar chart with heights for the percentage of the month total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767533#M243347</link>
      <description>What I meant was that I have already calculated the percents for each month but I don't know how to create a plot from a summary table.</description>
      <pubDate>Mon, 13 Sep 2021 19:21:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767533#M243347</guid>
      <dc:creator>kz_</dc:creator>
      <dc:date>2021-09-13T19:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: Create a bar chart with heights for the percentage of the month total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767537#M243348</link>
      <description>Which variable is that in the data you posted?</description>
      <pubDate>Mon, 13 Sep 2021 19:29:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767537#M243348</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-09-13T19:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create a bar chart with heights for the percentage of the month total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767539#M243349</link>
      <description>Here are instructions on how to create sample data:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;And you can find example code for various different bar charts here:&lt;BR /&gt;&lt;A href="https://robslink.com/SAS/ods2/aaaindex.htm" target="_blank"&gt;https://robslink.com/SAS/ods2/aaaindex.htm&lt;/A&gt;</description>
      <pubDate>Mon, 13 Sep 2021 19:34:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767539#M243349</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-09-13T19:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create a bar chart with heights for the percentage of the month total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767542#M243351</link>
      <description>Thanks, that seems like a useful link, but it doesn't include what I'm looking for.</description>
      <pubDate>Mon, 13 Sep 2021 20:00:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767542#M243351</guid>
      <dc:creator>kz_</dc:creator>
      <dc:date>2021-09-13T20:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create a bar chart with heights for the percentage of the month total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767544#M243352</link>
      <description>It's not in the data set - it's in the description. The percents that I calculated are in a separate, summary dataset.&lt;BR /&gt;&lt;BR /&gt;I can add it, but I will have to add more data.</description>
      <pubDate>Mon, 13 Sep 2021 20:01:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767544#M243352</guid>
      <dc:creator>kz_</dc:creator>
      <dc:date>2021-09-13T20:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: Create a bar chart with heights for the percentage of the month total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767545#M243353</link>
      <description>Maybe you can suggest how to create the percents as fake values. It seems that when making a bar chart, SAS counts the rows.</description>
      <pubDate>Mon, 13 Sep 2021 20:03:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767545#M243353</guid>
      <dc:creator>kz_</dc:creator>
      <dc:date>2021-09-13T20:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Create a bar chart with heights for the percentage of the month total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767567#M243362</link>
      <description>I'm sorry, your question is too unclear for me to answer. I don't know what your input data looks like or what you want to graph. Hopefully someone else will be able to assist you.</description>
      <pubDate>Mon, 13 Sep 2021 21:17:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767567#M243362</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-09-13T21:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Create a bar chart with heights for the percentage of the month total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767581#M243369</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/322176"&gt;@kz_&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;A nice alternative would be a way to construct a bar chart with user-defined heights for the bars. If you take out the repeated rows above, the height is specified by the percent on the right.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;basic, 1, 2019-01, 100%&lt;BR /&gt;basic, 1, 2019-02, 50%&lt;BR /&gt;basic, 3, 2019-02, 50% &lt;BR /&gt;normal, 1, 2019-01, 50%&lt;BR /&gt;normal, 2, 2019-01, 50%&lt;BR /&gt;normal, 2, 2019-02, 33%&lt;BR /&gt;normal, 3, 2019-02, 66%&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;First thing, this data makes more sense than the other.&lt;/P&gt;
&lt;PRE&gt;data noname; 
infile datalines delimiter= ',-';
input type $ group yr mo percent_of_month_by_type percent.;
yr_mo = mdy(mo,1,yr);
format yr_mo yymmd.;
datalines; 
basic,1,2019-01,100%
basic,1,2019-02,50%
basic,3,2019-02,50%
normal,1,2019-01,50%
normal,2,2019-01,50%
normal,2,2019-02,33%
normal,3,2019-02,66%
;

proc sort data=noname;
   by type yr_mo group;
run;

proc sgplot data=noname;
   by type;
   vbar yr_mo /response=percent_of_month_by_type group=group
      groupdisplay=cluster;
   format percent_of_month_by_type percent6.;
   yaxis values=(0 to 1 by .25) label="Percent";
run;&lt;/PRE&gt;
&lt;P&gt;Your date informat didn't work because there is no SAS supplied informat to read YYYY-MM data. So read the bits and use the MDY function as on way. Note use of two delimiters so the - is treated as a delimiter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is something needed to display "0" bars. One way is to include 0 values and use datalabel option, but no actual bar is visible just the number that would be 0% displayed near the axis.&lt;/P&gt;
&lt;P&gt;Another way would be to use a DATTRMAP data set to provide the option of setting specific colors for each group value and to display the value of the group variable even when not present. Search the forum for some examples as this is a specially structured data set with specific variables and I'm too lazy to go into all the details (again).&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 23:22:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/767581#M243369</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-09-13T23:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create a bar chart with heights for the percentage of the month total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/768359#M243719</link>
      <description>This almost works, but there is the same problem I was having. I want all the bars for group 1 to be adjacent to each other (I used the word 'cluster' in the question - maybe that was confusing).</description>
      <pubDate>Fri, 17 Sep 2021 19:42:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/768359#M243719</guid>
      <dc:creator>kz_</dc:creator>
      <dc:date>2021-09-17T19:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create a bar chart with heights for the percentage of the month total</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/768360#M243720</link>
      <description>In any case, I have decided on a different display of the data, so I will accept this as the solution.</description>
      <pubDate>Fri, 17 Sep 2021 19:42:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-bar-chart-with-heights-for-the-percentage-of-the-month/m-p/768360#M243720</guid>
      <dc:creator>kz_</dc:creator>
      <dc:date>2021-09-17T19:42:42Z</dc:date>
    </item>
  </channel>
</rss>

