<?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: Data labels at base of barline graph (Proc template, barline) in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876495#M23800</link>
    <description>&lt;P&gt;The best way is to use an axis table. I used an INNERMARGIN to protect the axis table from colliding with the bars. However, if you want the values inside of the bars, just remove the INNERMARGIN block.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc template;
  define statgraph barline_labels;
    begingraph;
      entrytitle "HAVE - Compliance Rate and Total Observations";
      layout overlay/
        xaxisopts=(display=(tickvalues))
        yaxisopts=(label="# Observations" griddisplay=on offsetmin=0
          linearopts=(viewmin=0 viewmax=500
          thresholdmin=0 thresholdmax=1));
        innermargin / align=bottom;
           axistable x=Unit value=Total_Obs2 / display=(values);
        endinnermargin;
        barchartparm x=Unit y=Total_Obs2 /
          fillattrs=(transparency=0.4 color=Royalblue)
          segmentlabeltype=auto;
        seriesplot x=Unit y=Compliance_Rate / yaxis=y2 name="series"
          lineattrs=(color=green thickness=3)
          markerattrs=(symbol=circlefilled size=100)
          datalabel=Compliance_Rate  DATALABELPOSITION=bottom ;
        discretelegend "series";
      endlayout;
    endgraph;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 18 May 2023 15:34:18 GMT</pubDate>
    <dc:creator>DanH_sas</dc:creator>
    <dc:date>2023-05-18T15:34:18Z</dc:date>
    <item>
      <title>Data labels at base of barline graph (Proc template, barline)</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876473#M23799</link>
      <description>&lt;P&gt;Hi, I am trying to have the bar labels (total_obs2) be displayed at the base of each bar in this barline graph. Below is my sas code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Unit $ Total_Obs2 Compliance_Rate;
  datalines;
a 139 85.5
b 419 90.2
c 636 92.7
d 4854 88.3
e 3807 84.6
f 1903 93.8
;
run;

/* Define the modified graph template */
proc template;
  define statgraph barline_labels;
    begingraph;
      entrytitle "HAVE - Compliance Rate and Total Observations";
      layout overlay/
        xaxisopts=(display=(tickvalues))
        yaxisopts=(label="# Observations" griddisplay=on offsetmin=0
          linearopts=(viewmin=0 viewmax=500
          thresholdmin=0 thresholdmax=1));
        barchartparm x=Unit y=Total_Obs2 /
          fillattrs=(transparency=0.4 color=Royalblue)
          segmentlabeltype=auto;
        seriesplot x=Unit y=Compliance_Rate / yaxis=y2 name="series" 
          lineattrs=(color=green thickness=3)
          markerattrs=(symbol=circlefilled size=100)
          datalabel=Compliance_Rate  DATALABELPOSITION=bottom ;
        discretelegend "series";
      endlayout;
    endgraph;
  end;
run;

/* Close the ODS HTML destination */
ods html close; 

/* Set the output directory and graph size */
ods listing gpath="c:file_path_location\Graphs";
ods graphics / reset imagename="HAVE" imagefmt=JPEG width=1200px height=700px;

/* Generate the modified graph with data labels */
proc sgrender data=have template=barline_labels;
  format Total_Obs2 comma12.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 May 2023 14:43:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876473#M23799</guid>
      <dc:creator>Scooby3g</dc:creator>
      <dc:date>2023-05-18T14:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: Data labels at base of barline graph (Proc template, barline)</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876495#M23800</link>
      <description>&lt;P&gt;The best way is to use an axis table. I used an INNERMARGIN to protect the axis table from colliding with the bars. However, if you want the values inside of the bars, just remove the INNERMARGIN block.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc template;
  define statgraph barline_labels;
    begingraph;
      entrytitle "HAVE - Compliance Rate and Total Observations";
      layout overlay/
        xaxisopts=(display=(tickvalues))
        yaxisopts=(label="# Observations" griddisplay=on offsetmin=0
          linearopts=(viewmin=0 viewmax=500
          thresholdmin=0 thresholdmax=1));
        innermargin / align=bottom;
           axistable x=Unit value=Total_Obs2 / display=(values);
        endinnermargin;
        barchartparm x=Unit y=Total_Obs2 /
          fillattrs=(transparency=0.4 color=Royalblue)
          segmentlabeltype=auto;
        seriesplot x=Unit y=Compliance_Rate / yaxis=y2 name="series"
          lineattrs=(color=green thickness=3)
          markerattrs=(symbol=circlefilled size=100)
          datalabel=Compliance_Rate  DATALABELPOSITION=bottom ;
        discretelegend "series";
      endlayout;
    endgraph;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 May 2023 15:34:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876495#M23800</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2023-05-18T15:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: Data labels at base of barline graph (Proc template, barline)</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876501#M23801</link>
      <description>&lt;P&gt;Do you mean show the value of Total_obs2 on the Axis? Inside the bar at the base? Outside the graph below the bar? Where do the values go?&lt;/P&gt;
&lt;P&gt;AXISTABLE might be appropriate.&lt;/P&gt;
&lt;P&gt;Or add an additional Y coordinate value and use a text plot (may be more flexible if you want the values inside the bar when close to the compliance_rate values).&lt;/P&gt;
&lt;PRE&gt;data have;
  input Unit $ Total_Obs2 Compliance_Rate ;
  texty=100;
  datalines;
a 139 85.5
b 419 90.2
c 636 92.7
d 4854 88.3
e 3807 84.6
f 1903 93.8
;
run;

/* Define the modified graph template */
proc template;
  define statgraph barline_labels;
    begingraph;
      entrytitle "HAVE - Compliance Rate and Total Observations";
      layout overlay/
        xaxisopts=(display=(tickvalues))
        yaxisopts=(label="# Observations" griddisplay=on offsetmin=0
          linearopts=(viewmin=0 viewmax=500
          thresholdmin=0 thresholdmax=1));
        barchartparm x=Unit y=Total_Obs2 /
          fillattrs=(transparency=0.4 color=Royalblue)
          segmentlabeltype=none;
        seriesplot x=Unit y=Compliance_Rate / yaxis=y2 name="series" 
          lineattrs=(color=green thickness=3)
          markerattrs=(symbol=circlefilled size=100)
          datalabel=Compliance_Rate  DATALABELPOSITION=bottom ;
        discretelegend "series";
        textplot x=unit y=texty text= Total_Obs2;
      endlayout;
    endgraph;
  end;
run;

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Running your example code you may have collisions with some of the Compliance_rate labels.&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 15:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876501#M23801</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-18T15:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Data labels at base of barline graph (Proc template, barline)</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876502#M23802</link>
      <description>Thank you!!!</description>
      <pubDate>Thu, 18 May 2023 15:53:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876502#M23802</guid>
      <dc:creator>Scooby3g</dc:creator>
      <dc:date>2023-05-18T15:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: Data labels at base of barline graph (Proc template, barline)</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876552#M23804</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15130"&gt;@DanH_sas&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;one more question &amp;gt;.&amp;lt;&lt;/P&gt;
&lt;P&gt;is it possible to add criteria to have the bars be a certain color if it meets it? I tried the below method but was not successful. Would you have any suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Unit $ Total_Obs2 Compliance_Rate;
  datalines;
a 139 85.5
b 419 90.2
c 636 92.7
d 4854 88.3
e 3807 84.6
f 1903 93.8
;
run;

/* Create a new variable for color */
data have;
  set have;
  if Compliance_Rate &amp;gt;= 95 then Color = 'Blue';
  else if Compliance_Rate &amp;gt; 85 then Color = 'Yellow';
  else Color = 'Red';
run;

/* Define the modified graph template */
/* Define the modified graph template */
proc template;
  define statgraph barline_labels;
    begingraph;
      entrytitle "HAVE - Compliance Rate and Total Observations";

      /* Define color mapping */
      discreteattrmap name="color_map";
      value '&amp;gt;=95' / fillattrs=(color=Blue transparency=0.4);
      value '&amp;lt;95 &amp;amp; &amp;gt;85' / fillattrs=(color=Yellow transparency=0.4);
      value '&amp;lt;85' / fillattrs=(color=Red transparency=0.4);
      enddiscreteattrmap;

      layout overlay/
        xaxisopts=(display=(tickvalues))
        yaxisopts=(label="# Observations" griddisplay=on offsetmin=0
          linearopts=(viewmin=0 viewmax=500
          thresholdmin=0 thresholdmax=1));
        innermargin / align=bottom;
           axistable x=Unit value=Total_Obs2 / display=(values);
        endinnermargin;
        barchartparm x=Unit y=Total_Obs2 /
          fillattrsmap "color_map";
        seriesplot x=Unit y=Compliance_Rate / yaxis=y2 name="series"
          lineattrs=(color=green thickness=3)
          markerattrs=(symbol=circlefilled size=100)
          datalabel=Compliance_Rate  DATALABELPOSITION=bottom ;
        discretelegend "series";
      endlayout;
    endgraph;
  end;
run;


/* Close the ODS HTML destination */
ods html close; 

/* Set the output directory and graph size */
ods listing gpath="C:file path\_Graphs";
ods graphics / reset imagename="HAVE" imagefmt=JPEG width=1200px height=700px;

/* Generate the modified graph with data labels */
proc sgrender data=have template=barline_labels;
  format Total_Obs2 comma12.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 19:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876552#M23804</guid>
      <dc:creator>Scooby3g</dc:creator>
      <dc:date>2023-05-18T19:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Data labels at base of barline graph (Proc template, barline)</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876562#M23805</link>
      <description>&lt;P&gt;I think&amp;nbsp; you are missing the association between the variable to use the attribute map and the map,&amp;nbsp; the DISCRETEATTRVAR statement. From the discretteattrmap documentation first the map is defined, then the variable to use the map.&lt;/P&gt;
&lt;PRE&gt;      discreteattrmap name="symbols" / trimleading=true ignorecase=true 
        discretelegendentrypolicy=attrmap;
        value "M" / markerattrs=(color=blue symbol=diamondfilled);
        value "F" / markerattrs=(color=green symbol=circlefilled); 
        value "U" / markerattrs=(color=red symbol=starfilled); 
      enddiscreteattrmap;

      /* Create attribute map variable GROUPMARKERS to associate attribute
         map SYMBOLS with column Sex */
      &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;discreteattrvar&lt;/STRONG&gt; &lt;/FONT&gt;attrvar=groupmarkers var=sex attrmap="symbols";
&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 May 2023 20:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876562#M23805</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-18T20:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Data labels at base of barline graph (Proc template, barline)</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876564#M23806</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; I added the &amp;nbsp;&lt;SPAN&gt;DISCRETEATTRVAR statement you had suggested and removed "fillattrs=(transparency=0.4 color=Color);" from the line of code but the color logic isnt applied. Did I miss something?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I may be approaching this wrong in the code...what i want to do is have each Bar (Total_obs2) be a specific color base on the HH_rate variable. Is that possible at all?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This is the code I used.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc template;
  define statgraph barline;
    begingraph;
      entrytitle "Have - HH Rate and Total HH Observations ";
		
	  
      /* Define color mapping */
	  	discreteattrmap name="color_map" / trimleading=true ignorecase=true ;
      value '&amp;gt;=95' / fillattrs=(color=Blue transparency=0.4);
      value '&amp;lt;95 &amp;amp; &amp;gt;85' / fillattrs=(color=Yellow transparency=0.4);
      value '&amp;lt;85' / fillattrs=(color=Red transparency=0.4);
      enddiscreteattrmap;
		
		discreteattrvar attrvar=groupmarkers var=color attrmap="color_map";

      layout overlay/
        xaxisopts=(display=(tickvalues))
        yaxisopts=(label="# HH Observations" griddisplay=on offsetmin=0
          linearopts=(viewmin=0 viewmax=500
          thresholdmin=0 thresholdmax=1))
        y2axisopts=(label="HH Rate %" griddisplay=on offsetmin=0
          linearopts=(viewmin=0 viewmax=100
          thresholdmin=0 thresholdmax=0)) ;
		  innermargin / align=bottom;
           axistable x=Unit value=Total_Obs2 / display=(values);
        endinnermargin;
        barchartparm x=Unit y=Total_Obs2 /;
/*          fillattrs=(transparency=0.4 color=Color);*/
        
        seriesplot x=Unit y=Compliance_Rate / yaxis=y2 name="series" 
          lineattrs=(color=green thickness=3)
          markerattrs=(symbol=circlefilled size=100)
          datalabel=Compliance_Rate; 
        discretelegend "series";
      endlayout;
    endgraph;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 20:58:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876564#M23806</guid>
      <dc:creator>Scooby3g</dc:creator>
      <dc:date>2023-05-18T20:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Data labels at base of barline graph (Proc template, barline)</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876572#M23808</link>
      <description>&lt;P&gt;I think your best option for this case is to use a Range Attributes Map and a COLORRESPONSE on your bar chart. You will not require the intermediate data set to map colors to ranges. As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;mentioned, you need to use an attrvar statement to bind the real variable and the attrmap together. That attrvar is used on the COLORRESPONSE option of the bar chart to color it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Define the modified graph template */
/* Define the modified graph template */
proc template;
  define statgraph barline_labels;
    begingraph;
      entrytitle "HAVE - Compliance Rate and Total Observations";

      /* Define color mapping */
      rangeattrmap name="color_map";
      range over / rangecolor=Blue;
      range 85-&amp;lt;95 / rangecolor=Yellow;
      range min-&amp;lt;85 / rangecolor=Red;
      endrangeattrmap;

      rangeattrvar attrvar=compvar var=Compliance_Rate attrmap="color_map";

      layout overlay/
        xaxisopts=(display=(tickvalues))
        yaxisopts=(label="# Observations" griddisplay=on offsetmin=0
          linearopts=(viewmin=0 viewmax=500
          thresholdmin=0 thresholdmax=1));
        innermargin / align=bottom;
           axistable x=Unit value=Total_Obs2 / display=(values);
        endinnermargin;
        barchartparm x=Unit y=Total_Obs2 / datatransparency=0.4
          colorresponse=compvar;
        seriesplot x=Unit y=Compliance_Rate / yaxis=y2 name="series"
          lineattrs=(color=green thickness=3)
          markerattrs=(symbol=circlefilled size=100)
          datalabel=Compliance_Rate  DATALABELPOSITION=bottom ;
        discretelegend "series";
      endlayout;
    endgraph;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 May 2023 21:59:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876572#M23808</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2023-05-18T21:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: Data labels at base of barline graph (Proc template, barline)</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876666#M23812</link>
      <description>&lt;P&gt;Thank you so much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15130"&gt;@DanH_sas&lt;/a&gt;&amp;nbsp;!!!!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 13:51:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Data-labels-at-base-of-barline-graph-Proc-template-barline/m-p/876666#M23812</guid>
      <dc:creator>Scooby3g</dc:creator>
      <dc:date>2023-05-19T13:51:11Z</dc:date>
    </item>
  </channel>
</rss>

