<?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: How to add datalabel when plotting in proc freq in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-datalabel-when-plotting-in-proc-freq/m-p/806473#M317746</link>
    <description>Hi @FreelanceReinhard and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&lt;BR /&gt;Thank you for your answers. I will have to accept that I shouldn't try to do it all with the PROC FREQ, but only use it for what it was made for.&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;</description>
    <pubDate>Thu, 07 Apr 2022 11:14:45 GMT</pubDate>
    <dc:creator>Lysegroentblad</dc:creator>
    <dc:date>2022-04-07T11:14:45Z</dc:date>
    <item>
      <title>How to add datalabel when plotting in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-datalabel-when-plotting-in-proc-freq/m-p/805819#M317436</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been attempting to scour the different forums to find a code for how to add data labels to the top of my bars when plotting in PROC FREQ.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was hoping to do it in one statement; not having to create a new output dataset.&lt;/P&gt;&lt;P&gt;My syntax so far is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Proc freq data = thesis  order=freq;
 Tables species /
       plots=freqplot(orient=vertical scale=percent);
	   datalabel;
	   BY site;
Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The proc works fine until i insert the datalabel code. I found the datalabel command in a code for sgplot, which I'm sure is why it doesn't work.&lt;/P&gt;&lt;P&gt;The log gives me this when including the datalabel command to my code:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Lysegroentblad_3-1649065893884.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70096iCD5CCF77ED6BAD9E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Lysegroentblad_3-1649065893884.png" alt="Lysegroentblad_3-1649065893884.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I knew it wouldn't work, as it turns up red when writing it in SAS. I also experimented with BARCHARTPARM but this does not work either, as I think this command requires a new dataset output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When just doing this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Proc freq data = thesis  order=freq;
 Tables species /
       plots=freqplot(orient=vertical scale=percent);
	   BY site;
Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;...I get these two charts:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Lysegroentblad_0-1649065444680.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70093i79B00BBCA1011CB3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Lysegroentblad_0-1649065444680.png" alt="Lysegroentblad_0-1649065444680.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Lysegroentblad_1-1649065473514.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70094iE65C72FD11593786/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Lysegroentblad_1-1649065473514.png" alt="Lysegroentblad_1-1649065473514.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;...which is exactly what I want, but i also want the %-values added on top of the bar, like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Lysegroentblad_2-1649065608539.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70095i49D3EF5D26FF12C5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Lysegroentblad_2-1649065608539.png" alt="Lysegroentblad_2-1649065608539.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;(...that chart is from an sgplot)&lt;BR /&gt;How do I code the same type of barlabel into my proc freq?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Maja&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 09:52:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-datalabel-when-plotting-in-proc-freq/m-p/805819#M317436</guid>
      <dc:creator>Lysegroentblad</dc:creator>
      <dc:date>2022-04-04T09:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to add datalabel when plotting in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-datalabel-when-plotting-in-proc-freq/m-p/805829#M317443</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416808"&gt;@Lysegroentblad&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think it's easier (than modifying an ODS template) and also the more flexible approach to apply PROC SGPLOT to an output dataset from PROC FREQ.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create test data for demonstration */

data have;
retain site 'M ';
input species $ _n_ @@;
if _n_&amp;gt;lag(_n_)&amp;gt;. then site='NI';
do _n_=1 to _n_;
  output;
end;
cards;
PA 167 PS 34 PC 19 LE 12 PM 8 PA 882 PS 19 LE 16 LM 8 PS3 6 FS 4 AA 2 PS2 1
;

/* Count species by site */

proc freq data=have order=freq;
by site;
tables species / out=want;
run;

/* Create bar charts from percentages */

title 'Distribution of species';

proc sgplot data=want;
by site;
format percent 6.2;
yaxis label='Percent' grid;
vbar species / response=percent categoryorder=respdesc datalabel;
run;

title;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Apr 2022 11:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-datalabel-when-plotting-in-proc-freq/m-p/805829#M317443</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-04-04T11:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to add datalabel when plotting in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-datalabel-when-plotting-in-proc-freq/m-p/805875#M317465</link>
      <description>&lt;P&gt;I very much agree with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you keep in mind that the plots generated by summary or analysis procedures, like Freq, Univariate or any of the regressions, are intended as aids to data exploration and learning about your results and not intended to be "camera ready for publication" you can lower your stress level about trying to force tools to do something they were not intended to to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider from a software design idea. SAS has provided a number of very powerful flexible graphing products in SGplot, SGpanel, SGrender plus Graphics Template Language. Why should they provide all of the tools and associated code into every single other procedure that generates graphs? That would multiply significantly the size of the software and the complexity of maintaining every single procedure that produces graphs. Basic appearance for basic graphs tells you want the data is doing. Use the proper tool to make reporting graphs.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 15:28:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-datalabel-when-plotting-in-proc-freq/m-p/805875#M317465</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-04-04T15:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to add datalabel when plotting in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-datalabel-when-plotting-in-proc-freq/m-p/806473#M317746</link>
      <description>Hi @FreelanceReinhard and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&lt;BR /&gt;Thank you for your answers. I will have to accept that I shouldn't try to do it all with the PROC FREQ, but only use it for what it was made for.&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Apr 2022 11:14:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-datalabel-when-plotting-in-proc-freq/m-p/806473#M317746</guid>
      <dc:creator>Lysegroentblad</dc:creator>
      <dc:date>2022-04-07T11:14:45Z</dc:date>
    </item>
  </channel>
</rss>

