<?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 Labeling values inside and outside a butterfly chart - EG 7.15/SAS 9.4 in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Labeling-values-inside-and-outside-a-butterfly-chart-EG-7-15-SAS/m-p/859413#M23521</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;First, thanks so much for the great answers I've gotten on all my questions. You are all the best! I'm almost there with my project and I just need help with one more part. . .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm running SAS 9.4 on EG 7.15 and I have a butterfly chart where some values show 4000% and most others show 5% - 20%. I am able to label everything (thanks to great code provided here) EXCEPT those that are massive values. So I need to label some inside the bars and some outside the bars. I know there's an option for this but that doesn't come in until SAS 9.5. Here's the code I'm using for now:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc format;
 picture posval low-&amp;lt;0='00000%'
 (prefix='-')
  0='9%'
  0&amp;lt;-high='00000%';
run;

data have;
call streaminit(123);
do date='01jan2022'd  to '20jan2022'd;
 value=rand('integer',-100,100);
 n=rand('integer',100,4000);
 group=ifc(value&amp;gt;0,'pos_diff','neg_diff');
 if value&amp;gt;0 then datalabel_pos=cats(value,"%|(",n,")");
  else datalabel_neg=cats(value,"%|(",n,")");
 output;
 call missing(datalabel_pos,datalabel_neg);
end;
format date date9.  value posval.;
run;



proc sgplot data=have;
hbarparm category=date response=value/group=group name='x' ;
text x=value y=date text=datalabel_pos/splitchar='|'   strip contributeoffsets=none 
SPLITCHAR='|'  SPLITJUSTIFY=left SPLITPOLICY=splitalways position=right ;
text x=value y=date text=datalabel_neg/splitchar='|'   strip contributeoffsets=none 
SPLITCHAR='|'  SPLITJUSTIFY=left SPLITPOLICY=splitalways position=left ;
keylegend 'x'/title='';
yaxis label=' ';
xaxis label=' ' offsetmin=0.1 offsetmax=0.1;
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Paula&lt;/P&gt;</description>
    <pubDate>Fri, 17 Feb 2023 18:12:02 GMT</pubDate>
    <dc:creator>SASGeek</dc:creator>
    <dc:date>2023-02-17T18:12:02Z</dc:date>
    <item>
      <title>Labeling values inside and outside a butterfly chart - EG 7.15/SAS 9.4</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Labeling-values-inside-and-outside-a-butterfly-chart-EG-7-15-SAS/m-p/859413#M23521</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;First, thanks so much for the great answers I've gotten on all my questions. You are all the best! I'm almost there with my project and I just need help with one more part. . .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm running SAS 9.4 on EG 7.15 and I have a butterfly chart where some values show 4000% and most others show 5% - 20%. I am able to label everything (thanks to great code provided here) EXCEPT those that are massive values. So I need to label some inside the bars and some outside the bars. I know there's an option for this but that doesn't come in until SAS 9.5. Here's the code I'm using for now:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc format;
 picture posval low-&amp;lt;0='00000%'
 (prefix='-')
  0='9%'
  0&amp;lt;-high='00000%';
run;

data have;
call streaminit(123);
do date='01jan2022'd  to '20jan2022'd;
 value=rand('integer',-100,100);
 n=rand('integer',100,4000);
 group=ifc(value&amp;gt;0,'pos_diff','neg_diff');
 if value&amp;gt;0 then datalabel_pos=cats(value,"%|(",n,")");
  else datalabel_neg=cats(value,"%|(",n,")");
 output;
 call missing(datalabel_pos,datalabel_neg);
end;
format date date9.  value posval.;
run;



proc sgplot data=have;
hbarparm category=date response=value/group=group name='x' ;
text x=value y=date text=datalabel_pos/splitchar='|'   strip contributeoffsets=none 
SPLITCHAR='|'  SPLITJUSTIFY=left SPLITPOLICY=splitalways position=right ;
text x=value y=date text=datalabel_neg/splitchar='|'   strip contributeoffsets=none 
SPLITCHAR='|'  SPLITJUSTIFY=left SPLITPOLICY=splitalways position=left ;
keylegend 'x'/title='';
yaxis label=' ';
xaxis label=' ' offsetmin=0.1 offsetmax=0.1;
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Paula&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2023 18:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Labeling-values-inside-and-outside-a-butterfly-chart-EG-7-15-SAS/m-p/859413#M23521</guid>
      <dc:creator>SASGeek</dc:creator>
      <dc:date>2023-02-17T18:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Labeling values inside and outside a butterfly chart - EG 7.15/SAS 9.4</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Labeling-values-inside-and-outside-a-butterfly-chart-EG-7-15-SAS/m-p/859521#M23522</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
 picture posval low-&amp;lt;0='00000%'
 (prefix='-')
  0='9%'
  0&amp;lt;-high='00000%';
run;

data have;
call streaminit(123);
do date='01jan2022'd  to '10jan2022'd;
 value=rand('integer',-100,100);
 n=rand('integer',100,4000);
 group=ifc(value&amp;gt;0,'pos_diff','neg_diff');
 datalabel=cats(value,"%|(",n,")");

 /*greater than 80 data label is inside,otherwise outside*/
 if value&amp;gt;=80 then _value=value-8;  
  else if value&amp;lt;=-80 then _value=value+8;
   else if 0&amp;lt;value&amp;lt;=80 then _value=value+8;
    else if -80&amp;lt;value&amp;lt;0 then _value=value-8;

 output;
end;
format date date9.  value posval.;
run;



proc sgplot data=have;
hbarparm category=date response=value/group=group name='x' ;
text x=_value y=date text=datalabel/splitchar='|'   strip contributeoffsets=none 
SPLITCHAR='|'  SPLITJUSTIFY=center SPLITPOLICY=splitalways position=center ;
keylegend 'x'/title='';
yaxis label=' ';
xaxis label=' ';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1676718542012.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80552i9D59326902F05437/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1676718542012.png" alt="Ksharp_0-1676718542012.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2023 11:10:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Labeling-values-inside-and-outside-a-butterfly-chart-EG-7-15-SAS/m-p/859521#M23522</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-02-18T11:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Labeling values inside and outside a butterfly chart - EG 7.15/SAS 9.4</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Labeling-values-inside-and-outside-a-butterfly-chart-EG-7-15-SAS/m-p/859913#M23523</link>
      <description>Thank you so very much. I truly appreciate your helping me through this project!</description>
      <pubDate>Tue, 21 Feb 2023 13:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Labeling-values-inside-and-outside-a-butterfly-chart-EG-7-15-SAS/m-p/859913#M23523</guid>
      <dc:creator>SASGeek</dc:creator>
      <dc:date>2023-02-21T13:16:03Z</dc:date>
    </item>
  </channel>
</rss>

