<?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: Overlay line on bar graph with proc sgplot in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/700945#M214581</link>
    <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194348"&gt;@GS2&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is this what you are looking for?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines delimiter=',';
input id impingment_point cum_pct;
datalines;
1,33,2
2,120,100
3,80,80
4,60,59
5,45,19
;
run;

proc format;
value impng_cat 0 - 19.99 = '0-19'
20 - 39.99 = '20-39'
40 - 59.99 = '40-59'
60 - 79.99 = '60-79'
80 - 99.99 = '80-99'
100 - 119.99 = '100-119'
120 - 139.99 = '120-139';
run;

proc sgplot data= have;
format impingment_point impng_cat.;
vbar impingment_point;
vline impingment_point / response=cum_pct y2axis;
xaxis label= '' type=discrete;
yaxis values=(0 5 10 15 20 25 30 35 40 45) label= 'Number of Patients';
label cum_pct = 'Cumulative Percent';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For posting code in the future please use the Insert SAS Code Button in the editor.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the display of a bar without any values I have no solution other than to add a row per missing value, not ideal I know but maybe color the missing value bar with something like mentioned here:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Graphics-Programming/How-to-make-a-bar-chart-and-assign-the-bar-color-based-on-the/td-p/190107" target="_blank"&gt;https://communities.sas.com/t5/Graphics-Programming/How-to-make-a-bar-chart-and-assign-the-bar-color-based-on-the/td-p/190107&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps and kind regards&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;</description>
    <pubDate>Mon, 23 Nov 2020 16:03:12 GMT</pubDate>
    <dc:creator>DavidHD</dc:creator>
    <dc:date>2020-11-23T16:03:12Z</dc:date>
    <item>
      <title>Overlay line on bar graph with proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/700925#M214564</link>
      <description>&lt;P&gt;Using SAS 9.4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying the code below to overlay a line on a bar graph:&lt;/P&gt;
&lt;P&gt;proc format;&lt;BR /&gt;value impng_cat 0 - 19.99 = '0-19'&lt;BR /&gt;20 - 39.99 = '20-39'&lt;BR /&gt;40 - 59.99 = '40-59'&lt;BR /&gt;60 - 79.99 = '60-79'&lt;BR /&gt;80 - 99.99 = '80-99'&lt;BR /&gt;100 - 119.99 = '100-119'&lt;BR /&gt;120 - 139.99 = '120-139';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sgplot data= check;&lt;BR /&gt;format impingment_point impng_cat.;&lt;BR /&gt;vbar impingment_point;&lt;BR /&gt;vline cum_pct;&lt;BR /&gt;xaxis label= '';&lt;BR /&gt;yaxis values=(0 5 10 15 20 25 30 35 40 45) label= 'Number of Patients';&lt;BR /&gt;label cum_pct = 'Cumulative Percent';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I get the following error when I run the code:&lt;/P&gt;
&lt;P&gt;"ERROR: The same category variable must be used for summarized plots."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example of data:&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input id impingment_point cum_pct delimiter= ',';&lt;BR /&gt;datalines;&lt;BR /&gt;1, 33, 2&lt;BR /&gt;2, 120, 100&lt;BR /&gt;3, 80, 80&lt;BR /&gt;4, 60, 59&lt;BR /&gt;5, 45, 19&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ideally, I would like&lt;/P&gt;
&lt;P&gt;1. bar graph with a line of the cummulative percentage&lt;/P&gt;
&lt;P&gt;2. Also, is it possible to show a category with 0 data point on a bar graph? The first category of 0-19.99 has 0 observations but I would like to be able to show this on the bar graph as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for any thoughts or suggestions&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 14:58:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/700925#M214564</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2020-11-23T14:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay line on bar graph with proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/700945#M214581</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194348"&gt;@GS2&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is this what you are looking for?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines delimiter=',';
input id impingment_point cum_pct;
datalines;
1,33,2
2,120,100
3,80,80
4,60,59
5,45,19
;
run;

proc format;
value impng_cat 0 - 19.99 = '0-19'
20 - 39.99 = '20-39'
40 - 59.99 = '40-59'
60 - 79.99 = '60-79'
80 - 99.99 = '80-99'
100 - 119.99 = '100-119'
120 - 139.99 = '120-139';
run;

proc sgplot data= have;
format impingment_point impng_cat.;
vbar impingment_point;
vline impingment_point / response=cum_pct y2axis;
xaxis label= '' type=discrete;
yaxis values=(0 5 10 15 20 25 30 35 40 45) label= 'Number of Patients';
label cum_pct = 'Cumulative Percent';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For posting code in the future please use the Insert SAS Code Button in the editor.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the display of a bar without any values I have no solution other than to add a row per missing value, not ideal I know but maybe color the missing value bar with something like mentioned here:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Graphics-Programming/How-to-make-a-bar-chart-and-assign-the-bar-color-based-on-the/td-p/190107" target="_blank"&gt;https://communities.sas.com/t5/Graphics-Programming/How-to-make-a-bar-chart-and-assign-the-bar-color-based-on-the/td-p/190107&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps and kind regards&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 16:03:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/700945#M214581</guid>
      <dc:creator>DavidHD</dc:creator>
      <dc:date>2020-11-23T16:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay line on bar graph with proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/700953#M214589</link>
      <description>Thank you for the help but this isn't exactly what I want. I tried this previously and this provides the percentage for each column so the line moves up and down. I would like a cumulative percentage line, in other words a line that goes up the entire graph from 0 to 100%</description>
      <pubDate>Mon, 23 Nov 2020 16:12:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/700953#M214589</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2020-11-23T16:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay line on bar graph with proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/700972#M214595</link>
      <description>&lt;P&gt;Can you provide an outline of what your desired graph looks like? Makes the whole thing easier.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 16:47:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/700972#M214595</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-11-23T16:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay line on bar graph with proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/700975#M214597</link>
      <description>&lt;P&gt;Attached is what excel can do in a PDF but with example data&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 16:58:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/700975#M214597</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2020-11-23T16:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay line on bar graph with proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/700977#M214598</link>
      <description>&lt;P&gt;This plot does not have anything to do with the sample data you posted, correct? Can you post the data behind this plot?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 17:05:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/700977#M214598</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-11-23T17:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay line on bar graph with proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/700981#M214600</link>
      <description>The plot is just an example of how I want the graph to look in the end. It is the same as type data as I post originally, just applying a format to the numbers</description>
      <pubDate>Mon, 23 Nov 2020 17:18:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/700981#M214600</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2020-11-23T17:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Overlay line on bar graph with proc sgplot</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/701039#M214615</link>
      <description>&lt;P&gt;I'm still not sure I understand the structure of your data. However, I think you can use this as a template. It definitely contains all the building blocks to answer both question 1 and two.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Feel free to ask.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id impingment_point cum_pct;
infile datalines dlm = ',';
datalines;
1, 33, 2
2, 120, 100
3, 80, 80
4, 60, 59
5, 45, 19
;

proc format;
value impng_cat 
0 - 19.99 = '0-19'
20 - 39.99 = '20-39'
40 - 59.99 = '40-59'
60 - 79.99 = '60-79'
80 - 99.99 = '80-99'
100 - 119.99 = '100-119'
120 - 139.99 = '120-139';
run;

proc summary data=have nway completetypes;
   class impingment_point / preloadfmt missing;
   format impingment_point impng_cat.;
   output out=temp;
run;

data plot;
   do until (z1);
      set temp end = z1;
      s + _FREQ_;
   end;
   do until (z2);
      set temp end = z2;
      c = _FREQ_ / s;
      cc + c;
      output;
   end;
run;

proc sgplot data=plot;
   vbarparm category = impingment_point response = _FREQ_ / nozerobars;
   series x = impingment_point y = cc / y2axis;
   format impingment_point impng_cat. cc percent.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Nov 2020 20:29:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Overlay-line-on-bar-graph-with-proc-sgplot/m-p/701039#M214615</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-11-23T20:29:55Z</dc:date>
    </item>
  </channel>
</rss>

