<?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: SGPLOT with VBAR percent labels and YAXIS with response sum labels in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SGPLOT-with-VBAR-percent-labels-and-YAXIS-with-response-sum/m-p/735364#M38589</link>
    <description>&lt;P&gt;One way that gets pretty close&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=SASHELP.CARS noautolegend;
	format Horsepower HPBins.;
   vbar horsepower / response=msrp stat=sum name='sum'

                     ;
	vbar Horsepower / response=MSRP stat=percent 
                    datalabel y2axis name='perc' ;
	xaxis values=('&amp;lt;100' '&amp;lt;200' '&amp;lt;300' '&amp;lt;400' '400+');
run;&lt;/PRE&gt;
&lt;P&gt;Personally I never had good luck with Gchart and created my own summary values so I could explicitly state variables and/or values.&lt;/P&gt;
&lt;P&gt;Which with SGPLOT and overlay of Textplot or similar provides a lot of control.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Apr 2021 22:06:58 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-04-19T22:06:58Z</dc:date>
    <item>
      <title>SGPLOT with VBAR percent labels and YAXIS with response sum labels</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SGPLOT-with-VBAR-percent-labels-and-YAXIS-with-response-sum/m-p/735350#M38587</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies if this has been answered. I've tried to find it in the topics to no avail... maybe not using the right key words?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;for&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Enterprise-Guide/GCHART-force-formatted-midpoints-for-continuous-numeric-field/td-p/734826" target="_self"&gt;helping me realize I should switch to SGPLOT&lt;/A&gt;&amp;nbsp;from using GCHART pretty much exclusively until now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is that I want to be able to do something in SGPLOT that I can do in GCHART, which is show percent labels above the VBARs, but show the SUMVAR sum on the Y Axis. So far in SGPLOT I have been able to get percent over both VBAR and on YAXIS, or response sums over VBAR and on YAXIS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is some code that shows first what I want to do in SGPLOT (but using GCHART as example), then second and third where I am so far with SGPLOT:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
	value HPBins
		low -&amp;lt; 100  = '&amp;lt;100'
		100 -&amp;lt; 200  = '&amp;lt;200'
		200 -&amp;lt; 300  = '&amp;lt;300'
		300 -&amp;lt; 400  = '&amp;lt;400'
		400 -  high = '400+';
run;
&lt;BR /&gt;/* FIRST */
title1 'What I want to show in SGPLOT, using GCHART as example';
title2 'GCHART: Percent label over VBAR, sumvar SUM on Y-Axis';
proc gchart data=SASHELP.CARS;
	format Horsepower HPBins.;
	vbar Horsepower / discrete sumvar=MSRP outside=percent;
run;
&lt;BR /&gt;/* SECOND */
title1 'Not quite there...';
title2 'SGPLOT: Response SUM labels over VBAR and on Y-Axis';
proc sgplot data=SASHELP.CARS;
	format Horsepower HPBins.;
	vbar Horsepower / response=MSRP datalabel;
	xaxis values=('&amp;lt;100' '&amp;lt;200' '&amp;lt;300' '&amp;lt;400' '400+');
	run;
run;
&lt;BR /&gt;/* THIRD */
title1 'Not quite there...';
title2 'SGPLOT: Percent labels over VBAR and on Y-Axis';
proc sgplot data=SASHELP.CARS;
	format Horsepower HPBins.;
	vbar Horsepower / response=MSRP stat=percent datalabel;
	xaxis values=('&amp;lt;100' '&amp;lt;200' '&amp;lt;300' '&amp;lt;400' '400+');
	run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 20:25:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SGPLOT-with-VBAR-percent-labels-and-YAXIS-with-response-sum/m-p/735350#M38587</guid>
      <dc:creator>subpar_actuary</dc:creator>
      <dc:date>2021-04-19T20:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT with VBAR percent labels and YAXIS with response sum labels</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SGPLOT-with-VBAR-percent-labels-and-YAXIS-with-response-sum/m-p/735363#M38588</link>
      <description>&lt;P&gt;Someone also asked this recently and I posted a solution....if you search through my post history you'll find it. The trick is to do it twice and suppress one plot or pre-summarize and customize the label with a different variable.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 21:10:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SGPLOT-with-VBAR-percent-labels-and-YAXIS-with-response-sum/m-p/735363#M38588</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-19T21:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT with VBAR percent labels and YAXIS with response sum labels</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SGPLOT-with-VBAR-percent-labels-and-YAXIS-with-response-sum/m-p/735364#M38589</link>
      <description>&lt;P&gt;One way that gets pretty close&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=SASHELP.CARS noautolegend;
	format Horsepower HPBins.;
   vbar horsepower / response=msrp stat=sum name='sum'

                     ;
	vbar Horsepower / response=MSRP stat=percent 
                    datalabel y2axis name='perc' ;
	xaxis values=('&amp;lt;100' '&amp;lt;200' '&amp;lt;300' '&amp;lt;400' '400+');
run;&lt;/PRE&gt;
&lt;P&gt;Personally I never had good luck with Gchart and created my own summary values so I could explicitly state variables and/or values.&lt;/P&gt;
&lt;P&gt;Which with SGPLOT and overlay of Textplot or similar provides a lot of control.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 22:06:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SGPLOT-with-VBAR-percent-labels-and-YAXIS-with-response-sum/m-p/735364#M38589</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-19T22:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT with VBAR percent labels and YAXIS with response sum labels</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SGPLOT-with-VBAR-percent-labels-and-YAXIS-with-response-sum/m-p/736656#M38680</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;thanks &lt;A href="https://communities.sas.com/t5/Graphics-Programming/sgplot-barchart-with-n-on-y-axis-and-floating-over-the-bars/m-p/730484" target="_self"&gt;I found the post&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pretty nifty way to rig the graph. I had some problems with the back (first) vbar showing up in the background, so I added transparency=1 which fixed that. I assume that issue is because the left and right axes are different bases, and since SAS fits each axis to nice round numbers, they sometimes don't line up horizontally.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Running&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;'s code and adding 'by make', you can see the issue with the Dodge graph and a number of others:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPLOT_Example_1.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58638i515ABC48F5EE19E3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SGPLOT_Example_1.PNG" alt="SGPLOT_Example_1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the final code that adds the transparency option (along with other options to get percents at by level, remove the y2axis labels, and change the ugly orange to blue&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":squinting_face_with_tongue:"&gt;😝&lt;/span&gt;. Thanks all for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sgplot data=SASHELP.CARS noautolegend pctlevel=by;
	format horsepower HPBins.;
	vbar horsepower / response=msrp stat=sum
		name='sum' transparency=1;
	vbar Horsepower / response=msrp stat=percent
		datalabel y2axis name='perc' fillattrs=(color=vligb) outlineattrs=(color=bib);
	xaxis values=('&amp;lt;100' '&amp;lt;200' '&amp;lt;300' '&amp;lt;400' '400+');
	y2axis display=none;
	by make;
	run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPLOT_Example_2.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58639iBB4293371A55D543/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SGPLOT_Example_2.PNG" alt="SGPLOT_Example_2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 19:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SGPLOT-with-VBAR-percent-labels-and-YAXIS-with-response-sum/m-p/736656#M38680</guid>
      <dc:creator>subpar_actuary</dc:creator>
      <dc:date>2021-04-23T19:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT with VBAR percent labels and YAXIS with response sum labels</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SGPLOT-with-VBAR-percent-labels-and-YAXIS-with-response-sum/m-p/736668#M38682</link>
      <description>&lt;P&gt;You could use VALUES=() lists on both axis to restrict the range of values, make things align and should address the "overlap"/"peek-a-bou" issue arising from the SAS underlying rules for building the axis range, or possibly as simple as MAX= on each axis.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 21:11:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SGPLOT-with-VBAR-percent-labels-and-YAXIS-with-response-sum/m-p/736668#M38682</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-23T21:11:15Z</dc:date>
    </item>
  </channel>
</rss>

