<?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: Plot percent of freq by groups in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Plot-percent-of-freq-by-groups/m-p/803242#M316284</link>
    <description>That didn't quite do what I want. It's giving me the % breakdown among the ethnic groups with one type of response, not by ethnic groups. What I want is that all responses should add up to 100% within one ethnic groups across the graph.</description>
    <pubDate>Mon, 21 Mar 2022 23:19:41 GMT</pubDate>
    <dc:creator>katslau</dc:creator>
    <dc:date>2022-03-21T23:19:41Z</dc:date>
    <item>
      <title>Plot percent of freq by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-percent-of-freq-by-groups/m-p/803233#M316279</link>
      <description>&lt;P&gt;I have a set of data which consists of different ethnic groups and their feedback in a survey. I want to plot their responses by groups but the group size is different by the ethnic groups. So I want to plot the percent of frequency using the individual group total instead of the whole population in the survey. Currently I use the group feature in SAS to plot but that really doesn't represent the actual picture. Here's an example of the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;title "Were you satifisfied with your trip?";&lt;/P&gt;&lt;P&gt;proc sgplot data= sasdata.cruise;&lt;BR /&gt;yaxis label= "Percent of Frequency";&lt;/P&gt;&lt;P&gt;vbar Q156_1/group=Q100 groupdisplay=cluster stat=percent datalabel ;&lt;BR /&gt;XAXIS discreteorder=unformatted DISPLAY=(NOLABEL);&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kathie&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot12.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69659iC8B8911289C606D7/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot12.png" alt="SGPlot12.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2022 21:47:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-percent-of-freq-by-groups/m-p/803233#M316279</guid>
      <dc:creator>katslau</dc:creator>
      <dc:date>2022-03-21T21:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: Plot percent of freq by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-percent-of-freq-by-groups/m-p/803238#M316281</link>
      <description>&lt;P&gt;Try adding the PCTLEVEL= Group to the VBAR statement if you want percentages calculated using the Group total.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2022 22:46:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-percent-of-freq-by-groups/m-p/803238#M316281</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-21T22:46:41Z</dc:date>
    </item>
    <item>
      <title>Re: Plot percent of freq by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-percent-of-freq-by-groups/m-p/803242#M316284</link>
      <description>That didn't quite do what I want. It's giving me the % breakdown among the ethnic groups with one type of response, not by ethnic groups. What I want is that all responses should add up to 100% within one ethnic groups across the graph.</description>
      <pubDate>Mon, 21 Mar 2022 23:19:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-percent-of-freq-by-groups/m-p/803242#M316284</guid>
      <dc:creator>katslau</dc:creator>
      <dc:date>2022-03-21T23:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: Plot percent of freq by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-percent-of-freq-by-groups/m-p/803283#M316298</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/392462"&gt;@katslau&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;That didn't quite do what I want. It's giving me the % breakdown among the ethnic groups with one type of response, not by ethnic groups. What I want is that all responses should add up to 100% within one ethnic groups across the graph.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your initial problem statement is not very clear. You stated "So I want to plot the percent of frequency using the individual group total instead of the whole population in the survey."&lt;/P&gt;
&lt;P&gt;You did not say what 'individual group' you wanted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think that you will likely need to summarize your data with another procedure before plotting, likely with Proc Freq creating an output data to get the percentages you want and then use a VBARPARM.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 09:53:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-percent-of-freq-by-groups/m-p/803283#M316298</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-22T09:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Plot percent of freq by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-percent-of-freq-by-groups/m-p/803311#M316309</link>
      <description>&lt;P&gt;Calculated it before PROC SGPLOT .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 set sashelp.heart;
run;


proc sql;
create table want as
select bp_status,Weight_Status,count(*)/
(select count(*) from have where Weight_Status=a.Weight_Status) 
as percent format=percent8.2
 from have as a
  where bp_status is not missing and Weight_Status is not missing
   group by bp_status,Weight_Status ;
quit;

proc sgplot data=want;
vbar bp_status/group=Weight_Status groupdisplay=cluster response=percent nostatlabel datalabel;
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-1647951048900.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69674i7A2AEC5B299A3DE2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1647951048900.png" alt="Ksharp_0-1647951048900.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 12:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-percent-of-freq-by-groups/m-p/803311#M316309</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-03-22T12:10:56Z</dc:date>
    </item>
  </channel>
</rss>

