<?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: Bubble plot: proportional scaling with discrete axes and axis spacing in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Bubble-plot-proportional-scaling-with-discrete-axes-and-axis/m-p/779919#M22309</link>
    <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You forgot about the variable length for label (which I named PlotGroup below), and the data labels were superimposed, but overall, your suggestion got me more or less what I wanted. This is how I tweaked it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;
    set demo;
    PlotGroup='Beds    ';Size=Beds;OUTPUT;
    PlotGroup='Patients'; size=NPatients;output;
run;
proc sgplot
	noautolegend
	noborder
	data=demo;
	y2axis display=none;
	bubble x=Hospital_Type y=Rx size=Size /group=PlotGroup nofill proportional bradiusmax=65.5 name="bubble";
    text x=Hospital_Type y=Rx text=size /position=center group=PlotGroup groupdisplay=cluster textattrs=(size=10 weight=bold);
    keylegend "bubble";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 12 Nov 2021 04:40:02 GMT</pubDate>
    <dc:creator>JacquesR</dc:creator>
    <dc:date>2021-11-12T04:40:02Z</dc:date>
    <item>
      <title>Bubble plot: proportional scaling with discrete axes and axis spacing</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Bubble-plot-proportional-scaling-with-discrete-axes-and-axis/m-p/779263#M22301</link>
      <description>&lt;P&gt;I am battling to get the right proportional representation I need.&lt;/P&gt;
&lt;P&gt;I am trying to plot the median number of patients and the median number of beds for different hospital types in different study arms.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;
  infile datalines dsd truncover;
  input @1 Hospital_Type $2. @4 Rx $1. @6 NHospitals 2. @9 NPatients 5.1 Beds 5.1;
  format Beds BEST.;
  label Hospital_Type="Hospital Type" Rx="Study Arm" NPatients="Frequency Count" Beds="Beds";
datalines;
BH E 1  291   117
BH T 1  567   287
BH G 4  655   265
DH E 8  196.5 109
DH T 10 290.5 113.5
DH G 10 217.5 99.5
PU E 12 89    50
PU T 7  47    60
PU G 9  61    48
RH E 7  37    34
RH T 10 47.5  32.5
RH G 5  30    16
;;;;
run;
proc print data=demo;run;
proc sgplot
	noautolegend
	noborder
	data=demo;
	y2axis display=none;
	bubble x=Hospital_Type y=Rx size=Beds
	/nofill proportional datalabel=Beds datalabelattrs=(color=black size=8 weight=bold) datalabelpos=center;
	bubble x=Hospital_Type y=Rx size=NPatients
	/y2axis nofill proportional lineattrs=(pattern=2) datalabel=NPatients datalabelattrs=(color=black size=8 weight=bold style=italic) datalabelpos=top;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is what I got:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot48.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65506i38276CE5CD9C8B81/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot48.png" alt="SGPlot48.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Absscale does not work, because the axes are discrete.&lt;/P&gt;
&lt;P&gt;I tried mucking around with bradiusmax, and got this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	bubble x=Hospital_Type y=Rx size=Beds
	/nofill proportional bradiusmax=28.7 datalabel=Beds datalabelattrs=(color=black size=8 weight=bold) datalabelpos=center;
	bubble x=Hospital_Type y=Rx size=NPatients
	/y2axis nofill proportional bradiusmax=65.5 lineattrs=(pattern=2) datalabel=NPatients datalabelattrs=(color=black size=8 weight=bold style=italic) datalabelpos=top;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot49.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65508i807CBB1DDA8EEAA5/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot49.png" alt="SGPlot49.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I'm not entirely convinced that that is right, but my eyes might be fooling me. I need each bubble to represent the proportional surface area of the actual value it represents.&lt;/P&gt;
&lt;P&gt;Also, I need the spacing on the y axis to be greater, so that the bubbles do not overlap and the labels are accordingly easier to interpret.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Nov 2021 03:28:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Bubble-plot-proportional-scaling-with-discrete-axes-and-axis/m-p/779263#M22301</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2021-11-09T03:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: Bubble plot: proportional scaling with discrete axes and axis spacing</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Bubble-plot-proportional-scaling-with-discrete-axes-and-axis/m-p/779307#M22302</link>
      <description>&lt;P&gt;You could try to change data structure and make graph bigger to avoid overlap problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data demo;
  infile datalines dsd truncover;
  input @1 Hospital_Type $2. @4 Rx $1. @6 NHospitals 2. @9 NPatients 5.1 Beds 5.1;
  format Beds BEST.;
  label Hospital_Type="Hospital Type" Rx="Study Arm" NPatients="Frequency Count" Beds="Beds";
datalines;
BH E 1  291   117
BH T 1  567   287
BH G 4  655   265
DH E 8  196.5 109
DH T 10 290.5 113.5
DH G 10 217.5 99.5
PU E 12 89    50
PU T 7  47    60
PU G 9  61    48
RH E 7  37    34
RH T 10 47.5  32.5
RH G 5  30    16
;;;;
run;

data demo1;
 set demo;
 label='Beds';size=Beds;output;
 label='NPatients'; size=NPatients;output;
run;

ods graphics/ height=600px width=800px;
proc sgplot 
 noautolegend
 noborder
 data=demo1;
 
 bubble x=Hospital_Type y=Rx size=size
 /group=label nofill proportional bradiusmax=65.5 datalabel=size
     datalabelattrs=(color=black size=8 weight=bold) datalabelpos=top;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Nov 2021 12:07:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Bubble-plot-proportional-scaling-with-discrete-axes-and-axis/m-p/779307#M22302</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-11-09T12:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: Bubble plot: proportional scaling with discrete axes and axis spacing</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Bubble-plot-proportional-scaling-with-discrete-axes-and-axis/m-p/779899#M22307</link>
      <description>&lt;P&gt;I think you need to first work on your input statement - I believe it is reading in some values incorrectly. For example, I believe it is reading in the DH E number of beds as 10.9, rather than 109.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Nov 2021 02:17:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Bubble-plot-proportional-scaling-with-discrete-axes-and-axis/m-p/779899#M22307</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2021-11-12T02:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: Bubble plot: proportional scaling with discrete axes and axis spacing</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Bubble-plot-proportional-scaling-with-discrete-axes-and-axis/m-p/779910#M22308</link>
      <description>&lt;P&gt;Nope, sorry, it's not that.&lt;/P&gt;
&lt;P&gt;What I mean is that the underlying data are sound, even though you have correctly spotted an error.&lt;/P&gt;
&lt;P&gt;I have the data as PROC FREQ output from a larger dataset and wanted to provide working data for whoever might want to take this on.&lt;/P&gt;
&lt;P&gt;I generated the data step from the actual underlying dataset with&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It didn't do a perfect job, so I modified it a bit, and messed it up.&lt;/P&gt;
&lt;P&gt;Apologies for that.&lt;/P&gt;
&lt;P&gt;Here is the correct data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;
  infile datalines dsd truncover;
  input @1 Hospital_Type $2. @4 Rx $1. @6 NHospitals 2. @9 NPatients 5.1 @15 Beds 5.1;
  label Hospital_Type="Hospital Type" Rx="Study Arm" NPatients="Frequency Count" Beds="Beds";
datalines;
BH E 1  291.0 117.0  
BH T 1  567.0 287.0  
BH G 4  655.0 265.0  
DH E 8  196.5 109.0  
DH T 10 290.5 113.5
DH G 10 217.5  99.5
PU E 12  89.0  50.0  
PU T 7   47.0  60.0  
PU G 9   61.0  48.0  
RH E 7   37.0  34.0  
RH T 10  47.5  32.5
RH G 5   30.0  16.0  
;;;;
run;
proc print data=demo;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Nov 2021 03:02:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Bubble-plot-proportional-scaling-with-discrete-axes-and-axis/m-p/779910#M22308</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2021-11-12T03:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Bubble plot: proportional scaling with discrete axes and axis spacing</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Bubble-plot-proportional-scaling-with-discrete-axes-and-axis/m-p/779919#M22309</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You forgot about the variable length for label (which I named PlotGroup below), and the data labels were superimposed, but overall, your suggestion got me more or less what I wanted. This is how I tweaked it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;
    set demo;
    PlotGroup='Beds    ';Size=Beds;OUTPUT;
    PlotGroup='Patients'; size=NPatients;output;
run;
proc sgplot
	noautolegend
	noborder
	data=demo;
	y2axis display=none;
	bubble x=Hospital_Type y=Rx size=Size /group=PlotGroup nofill proportional bradiusmax=65.5 name="bubble";
    text x=Hospital_Type y=Rx text=size /position=center group=PlotGroup groupdisplay=cluster textattrs=(size=10 weight=bold);
    keylegend "bubble";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Nov 2021 04:40:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Bubble-plot-proportional-scaling-with-discrete-axes-and-axis/m-p/779919#M22309</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2021-11-12T04:40:02Z</dc:date>
    </item>
  </channel>
</rss>

