<?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: In proc sgplot, how to make percentages appear at the top of each bar and counts inside each bar in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918580#M361827</link>
    <description>Thanks a lot. &lt;BR /&gt;It think this is the solution I was looking for. I will mark this as a solution soon. Thanks once again. &lt;BR /&gt;&lt;BR /&gt;- Dr. Abhijeet Safai</description>
    <pubDate>Fri, 01 Mar 2024 12:39:00 GMT</pubDate>
    <dc:creator>DrAbhijeetSafai</dc:creator>
    <dc:date>2024-03-01T12:39:00Z</dc:date>
    <item>
      <title>In proc sgplot, how to make percentages appear at the top of each bar and counts inside each bar</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918547#M361817</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Greetings!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to know how to display percent on top of each bar and counts inside each bar in a graph. Answer with the specific option for the same will be really helpful. Thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanking you,&lt;/P&gt;
&lt;P&gt;Yours sincerely,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Dr. Abhijeet Safai&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 09:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918547#M361817</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-03-01T09:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: In proc sgplot, how to make percentages appear at the top of each bar and counts inside each bar</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918548#M361818</link>
      <description>&lt;P&gt;Do you mean something like this:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Visual-Analytics/Representation-of-a-histogram-stacked-at-100/m-p/873814#M17175" target="_blank"&gt;https://communities.sas.com/t5/SAS-Visual-Analytics/Representation-of-a-histogram-stacked-at-100/m-p/873814#M17175&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 09:35:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918548#M361818</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-03-01T09:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: In proc sgplot, how to make percentages appear at the top of each bar and counts inside each bar</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918550#M361819</link>
      <description>&lt;P&gt;Yes &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;, the way in which the percent are appearing inside the bar, that is correct. However, the counts should be inside the bar, immediately below the top line of the bar and percent should be at the top of the bar.&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;- Dr. Abhijeet Safai&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 09:42:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918550#M361819</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-03-01T09:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: In proc sgplot, how to make percentages appear at the top of each bar and counts inside each bar</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918552#M361820</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*柱形图-分类变量*/
title  c=black  '按地区 分性别的柱形图';  
proc sort data=sashelp.heart out=temp;by bp_status;run;
proc freq data=temp noprint order=freq;
by bp_status;     
table status/out=temp2;  
run;
data temp3;
 set temp2;
 length _datalabel $ 40;
 _datalabel=cats(put(percent,8.2),'%/',count);
run;
proc sgplot data=temp3  ;
/*styleattrs datacolors=(grayaa lightblue lightred );*/
vbarparm category=bp_status response=count/ group=status  groupdisplay=cluster  
nooutline datalabel=_datalabel splitchar='/' datalabelpos=data ;
xaxis display=(nolabel);
keylegend /autooutline ;
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-1709286380373.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94288iBD36BBB7D01827B8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1709286380373.png" alt="Ksharp_0-1709286380373.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 09:46:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918552#M361820</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-03-01T09:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: In proc sgplot, how to make percentages appear at the top of each bar and counts inside each bar</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918553#M361821</link>
      <description>&lt;P&gt;For something like this the annotations data set will be required, give me a minute will try to prepare something.&lt;/P&gt;
&lt;P&gt;Do you have any ""test data"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 09:46:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918553#M361821</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-03-01T09:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: In proc sgplot, how to make percentages appear at the top of each bar and counts inside each bar</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918555#M361823</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp; for the response. Something like &lt;A href="https://www.datapine.com/blog/wp-content/uploads/2023/02/bullet-column.png" target="_self"&gt;this&lt;/A&gt; is expected. Only the difference is that - the counts inside need not be associated with some other bar (which are associated with the pink bar inside the blue bar as shown in this image) but the counts should be immediately below the bar (inside) and the percent should be immediately above the individual bar (outside). Thanks a lot.&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;- Dr. Abhijeet Safai&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 09:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918555#M361823</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-03-01T09:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: In proc sgplot, how to make percentages appear at the top of each bar and counts inside each bar</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918558#M361824</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.heart out=temp;
  by bp_status status;
run;

proc freq data=temp noprint order=data;
  by bp_status;       
  table status/out=temp2 outcum;  
run;

proc sort data=temp2;
  by bp_status status;
run;

data annotation;
  set temp2;
  by bp_status;

  lag_percent=LAG(cum_pct);

  function="text";
  drawspace="datavalue";
  justify="center";
  textsize=10;
  justify= "center";
  width=100;
  widthunit="percent";

  XC1=bp_status;

  if first.bp_status then lag_percent=0;
  
  label=put(count,9.-L);
  anchor="bottom";
  y1=lag_percent+1;
  output;

  label=strip(put(percent,8.2) !! '%');
  anchor="top";
  y1=cum_pct-1;
  output;
run; 

proc sgplot data=temp2 sganno=annotation ;
  vbar bp_status / 
  group=status 
  response=percent 
  grouporder=data 
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_0-1709290448563.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94289iA9DF0FE86B54371D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_0-1709290448563.png" alt="yabwon_0-1709290448563.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 10:54:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918558#M361824</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-03-01T10:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: In proc sgplot, how to make percentages appear at the top of each bar and counts inside each bar</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918563#M361825</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  call streaminit(123);
  do cat = "A","B","C";
    val1=rand('uniform',0,10);
    p=rand('uniform',0.2,0.5);
    val2=(1-p)*val1;
    output;
  end;
run;


proc sgplot data=have;
vbarparm category=cat response=val1 /
nooutline datalabel=val1 datalabelpos=data ;

vbarparm category=cat response=val2 /
nooutline datalabel=val2 datalabelpos=data 
BARWIDTH=0.5
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_0-1709291339169.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94290iD782E069BA2C1B9B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_0-1709291339169.png" alt="yabwon_0-1709291339169.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 11:09:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918563#M361825</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-03-01T11:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: In proc sgplot, how to make percentages appear at the top of each bar and counts inside each bar</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918580#M361827</link>
      <description>Thanks a lot. &lt;BR /&gt;It think this is the solution I was looking for. I will mark this as a solution soon. Thanks once again. &lt;BR /&gt;&lt;BR /&gt;- Dr. Abhijeet Safai</description>
      <pubDate>Fri, 01 Mar 2024 12:39:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918580#M361827</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-03-01T12:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: In proc sgplot, how to make percentages appear at the top of each bar and counts inside each bar</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918720#M361898</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=sashelp.heart;
vbar bp_status/stat=freq datalabel legendlabel='Freq' ;
vbar bp_status/stat=percent datalabel y2axis barwidth=0.6 legendlabel='Percent';
yaxis  valueattrs=graphdata1 labelattrs=graphdata1;
y2axis values=(0 to 1 by 0.2) valueattrs=graphdata2 labelattrs=graphdata2;
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-1709452934116.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94323i45F7ABB24F2A6486/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1709452934116.png" alt="Ksharp_0-1709452934116.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2024 08:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918720#M361898</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-03-03T08:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: In proc sgplot, how to make percentages appear at the top of each bar and counts inside each bar</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918724#M361901</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.heart out=temp;by bp_status;run;
proc freq data=temp noprint order=freq;
/*by bp_status;     */
table bp_status/out=temp2;  
run;
data temp3;
 set temp2;
 length _datalabel $ 40;
 _datalabel=cats(count,'/',put(percent,8.2),'%');
run;
proc sgplot data=temp3  noautolegend;
vbarparm category=bp_status response=count /nooutline;
text x=bp_status y=count text=_datalabel/splitchar='/' SPLITPOLICY=splitalways  strip contributeoffsets=none;
xaxis display=(nolabel);
yaxis offsetmax=0.1;
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-1709456079769.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94324iED9B92367B198FDE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1709456079769.png" alt="Ksharp_0-1709456079769.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2024 08:54:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918724#M361901</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-03-03T08:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: In proc sgplot, how to make percentages appear at the top of each bar and counts inside each bar</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918759#M361912</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;, Correct! Thanks a lot!&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;- Dr. Abhijeet Safai&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 05:06:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-proc-sgplot-how-to-make-percentages-appear-at-the-top-of-each/m-p/918759#M361912</guid>
      <dc:creator>DrAbhijeetSafai</dc:creator>
      <dc:date>2024-03-04T05:06:18Z</dc:date>
    </item>
  </channel>
</rss>

