<?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: Sgplot grouping variables together on x-axis? in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-grouping-variables-together-on-x-axis/m-p/759963#M21796</link>
    <description>&lt;P&gt;A possibility&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create a custom format assigning multiple states to regions&lt;/LI&gt;
&lt;LI&gt;PROC SUMMARY to create the mean by region&lt;/LI&gt;
&lt;LI&gt;PROC SGPLOT VBAR on the output from PROC SUMMARY&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Fri, 06 Aug 2021 14:15:20 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-08-06T14:15:20Z</dc:date>
    <item>
      <title>Sgplot grouping variables together on x-axis?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-grouping-variables-together-on-x-axis/m-p/759955#M21795</link>
      <description>&lt;P&gt;Hi, I am wanting to know if there is an easy way to group variables together on the x-axis. I have a column for the states, and and on each of their row I have gas prices. I would like my barchart graph to have 4 regions on the bottom, region 1,2,3,4. With the mean of gas prices for the states in those regions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to produce a graph that has 50 points on the x axis, is there a way I can say these states should be in region 1, and these states should be in region 2, and so on?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Aug 2021 14:01:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-grouping-variables-together-on-x-axis/m-p/759955#M21795</guid>
      <dc:creator>helloagainoh2</dc:creator>
      <dc:date>2021-08-06T14:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sgplot grouping variables together on x-axis?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-grouping-variables-together-on-x-axis/m-p/759963#M21796</link>
      <description>&lt;P&gt;A possibility&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create a custom format assigning multiple states to regions&lt;/LI&gt;
&lt;LI&gt;PROC SUMMARY to create the mean by region&lt;/LI&gt;
&lt;LI&gt;PROC SGPLOT VBAR on the output from PROC SUMMARY&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Fri, 06 Aug 2021 14:15:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-grouping-variables-together-on-x-axis/m-p/759963#M21796</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-08-06T14:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sgplot grouping variables together on x-axis?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-grouping-variables-together-on-x-axis/m-p/759973#M21797</link>
      <description>&lt;P&gt;You don't need to summarize the data. The VBAR statement will do that for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
length State $2;
input State Gas;
datalines;
AL      2.89
FL      2.93
CA      3.55
NV      2.99
MN      3.05
MI      3.12
NY      3.24
MA      3.33
;

proc format;
value $Region
 'AL', 'FL' /* etc */ = 'SE'
 'NY', 'MA' /* etc */ = 'NE'
 'MN', 'MI' /* etc */ = 'MW'
 'CA', 'NV' /* etc */ = 'W';
run;

proc sgplot data=Have;
format State $Region.;
vbar State / response=Gas stat=mean;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Aug 2021 14:57:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-grouping-variables-together-on-x-axis/m-p/759973#M21797</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-08-06T14:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Sgplot grouping variables together on x-axis?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sgplot-grouping-variables-together-on-x-axis/m-p/760160#M21812</link>
      <description>&lt;P&gt;If I'm understanding correctly I think I have something close to what you're looking for.&amp;nbsp; All you would need is to add another column containing the region you want each state to be in for the grouping.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgpanel data=sashelp.cars;
    panelby origin / rows=1 columns=3 novarname uniscale=row;
    vbar type / response=msrp stat=mean;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used SGPANEL so that you can use your region grouping variable in the panels while keeping the TYPE variable (which would be the states in your case) on the x-axis for categorizing the bars.&amp;nbsp; There are options I believe for removing the borders and such, only option I didn't see was a way to move the grouping labels (origin in the example) to the bottom.&amp;nbsp; The Uniscale option makes each panel able to have unique column axes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="SGPanel2.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62371iB30904A86422772B/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPanel2.png" alt="SGPanel2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Aug 2021 15:18:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sgplot-grouping-variables-together-on-x-axis/m-p/760160#M21812</guid>
      <dc:creator>JeffMeyers</dc:creator>
      <dc:date>2021-08-07T15:18:53Z</dc:date>
    </item>
  </channel>
</rss>

