<?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 How do I plot both an Overall and Stratified Graph on the Same Graph using SGPLOT Procedure in SAS Visual Analytics</title>
    <link>https://communities.sas.com/t5/SAS-Visual-Analytics/How-do-I-plot-both-an-Overall-and-Stratified-Graph-on-the-Same/m-p/967643#M18792</link>
    <description>&lt;P&gt;Dear SAS Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to plot both an overall and a stratified graph on the same graph procedure. I have been using the following procedures for the overall and stratified graphs separately, but I would like to combine them into one graph showing the percentages for both the overall and stratified graphs.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Creating Data with Categorical Variables for Satisfaction and Age Categories*/&lt;BR /&gt;Data Customer_response; set Origina_Data;&lt;BR /&gt;if Response="Satisfied" then Satisfaction=1;&lt;BR /&gt;else if Response "Not Satisfied" then Satisfaction=2;&lt;/P&gt;&lt;P&gt;if Age lt 35 then Age_Category=1&lt;BR /&gt;else if Age ge 35 then Age_Category=2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is that SAS code that works for the overall graph.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Creates an Overall Graph for the Satisfaction Variable showing percentages */&lt;BR /&gt;title; /* Removes all titles */&lt;BR /&gt;Proc sgplot data=Customer_response;&lt;BR /&gt;format Satisfaction.;&lt;BR /&gt;styleattrs datacolors=(VIGB VIPK) ;&lt;BR /&gt;vbar Satisfaction / group=Satisfaction stat=percent; /* Creates a vertical bar chart showing percentages */&lt;BR /&gt;LABEL Satisfaction='Satisfaction Category';&lt;BR /&gt;XAXIS LABEL = 'Satisfaction';&lt;BR /&gt;XAXIS VALUES =("1" "2");&lt;BR /&gt;YAXIS LABEL = 'Proportion of Participants According to Satisfaction';&lt;BR /&gt;keylegend / title="Customer Satisfaction";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the program that seems to produce the desired age stratified graph.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* Frequency plot of percentages for two variables */&lt;BR /&gt;Proc freq data=Customer_response;&lt;BR /&gt;tables Age_Category *Satisfaction / plots=FreqPlot(twoway=cluster scale=Percent) out=Freq2Out;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* Dividing by 100 and apply PERCENTw.d format*/&lt;BR /&gt;Data Freq2Out;&lt;BR /&gt;set Freq2Out;&lt;BR /&gt;Percent = Percent / 100;&lt;BR /&gt;format Percent PERCENT5.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Graph showing Satisfaction Stratified by Age Categories*/&lt;BR /&gt;ods listing style=listing;&lt;BR /&gt;ods graphics / width=7.8in height=7in;&lt;BR /&gt;*title 'Graph showing Satisfaction Stratified by Age Categories';&lt;BR /&gt;Proc sgplot data=Freq2Out;&lt;BR /&gt;format Satisfaction.;&lt;BR /&gt;styleattrs datacolors=(VIGB VIPK) ;&lt;BR /&gt;vbar Age_Category / group=Satisfaction groupdisplay=cluster response=Percent;&lt;BR /&gt;XAXIS LABEL = 'Age Category';&lt;BR /&gt;YAXIS LABEL = 'Proportion of Participants According to Satisfaction Categories'&lt;BR /&gt;VALUES =("1" "2") VALUESDISPLAY=("Satisfied" "Not Satisfied");&lt;BR /&gt;keylegend / title="Satisfaction";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Those two graphs are currently drawn separately, but I want to have both the overall and stratified graphs combined on the same graph in a single procedure, with the overall graph on the left side and the stratified on the right side of the graph creates. I will be glad to receive assistance from the community. If there is any other more efficient procedure, I would like to see a sample code that I can use to produced those graphs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Wed, 28 May 2025 19:31:08 GMT</pubDate>
    <dc:creator>DavidsM</dc:creator>
    <dc:date>2025-05-28T19:31:08Z</dc:date>
    <item>
      <title>How do I plot both an Overall and Stratified Graph on the Same Graph using SGPLOT Procedure</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/How-do-I-plot-both-an-Overall-and-Stratified-Graph-on-the-Same/m-p/967643#M18792</link>
      <description>&lt;P&gt;Dear SAS Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to plot both an overall and a stratified graph on the same graph procedure. I have been using the following procedures for the overall and stratified graphs separately, but I would like to combine them into one graph showing the percentages for both the overall and stratified graphs.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Creating Data with Categorical Variables for Satisfaction and Age Categories*/&lt;BR /&gt;Data Customer_response; set Origina_Data;&lt;BR /&gt;if Response="Satisfied" then Satisfaction=1;&lt;BR /&gt;else if Response "Not Satisfied" then Satisfaction=2;&lt;/P&gt;&lt;P&gt;if Age lt 35 then Age_Category=1&lt;BR /&gt;else if Age ge 35 then Age_Category=2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is that SAS code that works for the overall graph.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Creates an Overall Graph for the Satisfaction Variable showing percentages */&lt;BR /&gt;title; /* Removes all titles */&lt;BR /&gt;Proc sgplot data=Customer_response;&lt;BR /&gt;format Satisfaction.;&lt;BR /&gt;styleattrs datacolors=(VIGB VIPK) ;&lt;BR /&gt;vbar Satisfaction / group=Satisfaction stat=percent; /* Creates a vertical bar chart showing percentages */&lt;BR /&gt;LABEL Satisfaction='Satisfaction Category';&lt;BR /&gt;XAXIS LABEL = 'Satisfaction';&lt;BR /&gt;XAXIS VALUES =("1" "2");&lt;BR /&gt;YAXIS LABEL = 'Proportion of Participants According to Satisfaction';&lt;BR /&gt;keylegend / title="Customer Satisfaction";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the program that seems to produce the desired age stratified graph.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* Frequency plot of percentages for two variables */&lt;BR /&gt;Proc freq data=Customer_response;&lt;BR /&gt;tables Age_Category *Satisfaction / plots=FreqPlot(twoway=cluster scale=Percent) out=Freq2Out;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* Dividing by 100 and apply PERCENTw.d format*/&lt;BR /&gt;Data Freq2Out;&lt;BR /&gt;set Freq2Out;&lt;BR /&gt;Percent = Percent / 100;&lt;BR /&gt;format Percent PERCENT5.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Graph showing Satisfaction Stratified by Age Categories*/&lt;BR /&gt;ods listing style=listing;&lt;BR /&gt;ods graphics / width=7.8in height=7in;&lt;BR /&gt;*title 'Graph showing Satisfaction Stratified by Age Categories';&lt;BR /&gt;Proc sgplot data=Freq2Out;&lt;BR /&gt;format Satisfaction.;&lt;BR /&gt;styleattrs datacolors=(VIGB VIPK) ;&lt;BR /&gt;vbar Age_Category / group=Satisfaction groupdisplay=cluster response=Percent;&lt;BR /&gt;XAXIS LABEL = 'Age Category';&lt;BR /&gt;YAXIS LABEL = 'Proportion of Participants According to Satisfaction Categories'&lt;BR /&gt;VALUES =("1" "2") VALUESDISPLAY=("Satisfied" "Not Satisfied");&lt;BR /&gt;keylegend / title="Satisfaction";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Those two graphs are currently drawn separately, but I want to have both the overall and stratified graphs combined on the same graph in a single procedure, with the overall graph on the left side and the stratified on the right side of the graph creates. I will be glad to receive assistance from the community. If there is any other more efficient procedure, I would like to see a sample code that I can use to produced those graphs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2025 19:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/How-do-I-plot-both-an-Overall-and-Stratified-Graph-on-the-Same/m-p/967643#M18792</guid>
      <dc:creator>DavidsM</dc:creator>
      <dc:date>2025-05-28T19:31:08Z</dc:date>
    </item>
  </channel>
</rss>

