<?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 label inside the bars in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/data-label-inside-the-bars/m-p/930542#M366117</link>
    <description>&lt;P&gt;Perfect. Thanks!&lt;/P&gt;</description>
    <pubDate>Sat, 01 Jun 2024 18:48:45 GMT</pubDate>
    <dc:creator>mateescu</dc:creator>
    <dc:date>2024-06-01T18:48:45Z</dc:date>
    <item>
      <title>data label inside the bars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-label-inside-the-bars/m-p/930521#M366105</link>
      <description>&lt;P&gt;I am creating a bar plot but would like to have the data labels inside the bars at the bottom. Here is my code so far. Thanks!&lt;/P&gt;&lt;P&gt;PS. Also - when I insert the sas code here, how do I make it look like the original sas code (colors)? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data test;
input id group var;
cards;

1 1 2.236
2 1 4.569
3 2 3.694
4 2 1.256
;
proc sgplot data=test;
vbar group / response=var stat=mean datalabel group=group fillattrs=(color=royalblue) DATALABELATTRS=(size=14);
xaxis display=(noline noticks) labelattrs=(size=16) valueattrs=(size=16) ;
yaxis display=(noline) labelattrs=(size=16) valueattrs=(size=16);
keylegend / noborder location=outside position=bottom valueattrs=(size=12);
format var 6.2;
title height=16pt 'var by group';
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Jun 2024 13:12:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-label-inside-the-bars/m-p/930521#M366105</guid>
      <dc:creator>mateescu</dc:creator>
      <dc:date>2024-06-01T13:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: data label inside the bars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-label-inside-the-bars/m-p/930524#M366107</link>
      <description>&lt;P&gt;I would create a dataset with the means first and use the VBARPARM and TEXT statements with that data.&amp;nbsp; I added the variable yposition to your data step to place the labels at the bottom.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data test;
input id group var;
yposition = 0;
cards;

1 1 2.236
2 1 4.569
3 2 3.694
4 2 1.256
;

proc means data = test noprint;
	var var;
	by group;
	output out = have mean = / autoname;
	id yposition;
run;

proc sgplot data=have;
vbarparm category = group response = var_Mean / fillattrs=(color=royalblue);
xaxis display=(noline noticks) labelattrs=(size=16) valueattrs=(size=16) ;
yaxis display=(noline) labelattrs=(size=16) valueattrs=(size=16);
keylegend / noborder location=outside position=bottom valueattrs=(size=12);
format var_Mean 6.2;
title height=16pt 'var by group';
text x = group y = yposition text = var_Mean / position = top contributeoffsets = none textattrs = (size = 14);
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Source:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2022/04/23/optimizing-bar-label-placement/" target="_self"&gt;https://blogs.sas.com/content/graphicallyspeaking/2022/04/23/optimizing-bar-label-placement/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get the SAS code with the colors, it may work to try pasting the code from your SAS editor into MS Word.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jun 2024 15:25:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-label-inside-the-bars/m-p/930524#M366107</guid>
      <dc:creator>dpalmer1</dc:creator>
      <dc:date>2024-06-01T15:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: data label inside the bars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-label-inside-the-bars/m-p/930532#M366110</link>
      <description>&lt;P&gt;This is great, thanks. However, I made up that example. I am actually running some regressions, putting out the LSMeans and then try to plot those. I expended the code on this example so you can see the set up. How do I get the data labels inside the bars in this case? Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data test;
input id group var;
cards;

1 1 2.236
2 1 4.569
3 2 3.694
4 2 1.256
;

proc glm data=test; 
class group ;
model  Var	=    group  / Solution ss3;
output out=GLMout Predicted=Pred lclm=lclm uclm=uclm;
lsmeans group/ cl;
ods output LSMeanCL=LS;
run;

proc sgplot data=LS;
vbar group / response=LSMean stat=mean datalabel group=group fillattrs=(color=royalblue) DATALABELATTRS=(size=14) datalabelpos=data;
xaxis display=(noline noticks) labelattrs=(size=16) valueattrs=(size=16) ;
yaxis display=(noline) labelattrs=(size=16) valueattrs=(size=16);
keylegend / noborder location=outside position=bottom valueattrs=(size=12);
format LSMean 6.2;
title height=16pt 'var by group';
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jun 2024 16:53:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-label-inside-the-bars/m-p/930532#M366110</guid>
      <dc:creator>mateescu</dc:creator>
      <dc:date>2024-06-01T16:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: data label inside the bars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-label-inside-the-bars/m-p/930539#M366115</link>
      <description>&lt;P&gt;Add a data step after LSMeans are output from PROC GLM:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data LS;
	set LS;
	yposition = 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Use the modified PROC SGPLOT code with the VBARPARM and TEXT statements:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sgplot data=LS;
vbarparm category = group response=LSMean / group=group fillattrs=(color=royalblue);
xaxis display=(noline noticks) labelattrs=(size=16) valueattrs=(size=16) ;
yaxis display=(noline) labelattrs=(size=16) valueattrs=(size=16);
keylegend / noborder location=outside position=bottom valueattrs=(size=12);
format LSMean 6.2;
title height=16pt 'var by group';
text x = group y = yposition text = LSMean / position = top contributeoffsets = none textattrs = (size = 14);
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jun 2024 17:45:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-label-inside-the-bars/m-p/930539#M366115</guid>
      <dc:creator>dpalmer1</dc:creator>
      <dc:date>2024-06-01T17:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: data label inside the bars</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-label-inside-the-bars/m-p/930542#M366117</link>
      <description>&lt;P&gt;Perfect. Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jun 2024 18:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-label-inside-the-bars/m-p/930542#M366117</guid>
      <dc:creator>mateescu</dc:creator>
      <dc:date>2024-06-01T18:48:45Z</dc:date>
    </item>
  </channel>
</rss>

