<?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 multiple bar graph problem with set up in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/multiple-bar-graph-problem-with-set-up/m-p/778668#M247890</link>
    <description>&lt;P&gt;I have data and would like to show in a bar chart. In one position Active_today, Active_prior in two colors and in the other Expired_today and expired prior. To show how values change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code to create tabel for graph :&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc sql ;
create table graphbar as
select *
from
(select "ACTIVE_TODAY" as Type, 
sum(ak.ACTIVE_TODAY) as Sum,
"ACTIVE_PRIOR" as Type1, 
sum(ak.ACTIVE_PRIOR) as Sum1
from diff_policy as ak)
union
(select "EXPIRED_TODAY" as Typ2, 
sum(wy.EXPIRED_TODAY) as SUM2,
"EXPIRED_PRIOR" as Type3, 
sum(wy.EXPIRED_PRIOR) as Sum3
from diff_policy as wy)
;
quit;
&lt;/LI-CODE&gt;
&lt;P&gt;My data:&lt;/P&gt;
&lt;TABLE border="1" width="100.00000000000001%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="34.73132372214941%" height="30px"&gt;Type&lt;/TD&gt;
&lt;TD width="15.59633027522936%" height="30px"&gt;Sum&lt;/TD&gt;
&lt;TD width="34.07601572739188%" height="30px"&gt;Type1&lt;/TD&gt;
&lt;TD width="15.59633027522936%" height="30px"&gt;Sum1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="34.73132372214941%" height="30px"&gt;ACTIVE_TODAY&lt;/TD&gt;
&lt;TD width="15.59633027522936%" height="30px"&gt;122265&lt;/TD&gt;
&lt;TD width="34.07601572739188%" height="30px"&gt;ACTIVE_PRIOR&lt;/TD&gt;
&lt;TD width="15.59633027522936%" height="30px"&gt;122641&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="34.73132372214941%" height="30px"&gt;EXPIRED_TODAY&lt;/TD&gt;
&lt;TD width="15.59633027522936%" height="30px"&gt;6790&lt;/TD&gt;
&lt;TD width="34.07601572739188%" height="30px"&gt;EXPIRED_PRIOR&lt;/TD&gt;
&lt;TD width="15.59633027522936%" height="30px"&gt;1744&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When i run below code:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc sgplot data=graphbar;
vbarparm category=Type response=Sum / discreteoffset=-0.17 barwidth=0.3;
vbarparm category=Type1 response=Sum1 / discreteoffset=0.17 barwidth=0.3;
vbarparm category=Type2 response=Sum2 / discreteoffset=0.17 barwidth=0.3;
vbarparm category=Type3 response=Sum3 / discreteoffset=0.17 barwidth=0.3;

run;&lt;/LI-CODE&gt;
&lt;P&gt;log shows that Type/Sum variable not found. How to change data and proc sgplot to get some like a below :&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Gieorgie_0-1636096677207.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65427i68D826DC49E6CBB4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Gieorgie_0-1636096677207.png" alt="Gieorgie_0-1636096677207.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 05 Nov 2021 07:18:06 GMT</pubDate>
    <dc:creator>Gieorgie</dc:creator>
    <dc:date>2021-11-05T07:18:06Z</dc:date>
    <item>
      <title>multiple bar graph problem with set up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-bar-graph-problem-with-set-up/m-p/778668#M247890</link>
      <description>&lt;P&gt;I have data and would like to show in a bar chart. In one position Active_today, Active_prior in two colors and in the other Expired_today and expired prior. To show how values change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code to create tabel for graph :&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc sql ;
create table graphbar as
select *
from
(select "ACTIVE_TODAY" as Type, 
sum(ak.ACTIVE_TODAY) as Sum,
"ACTIVE_PRIOR" as Type1, 
sum(ak.ACTIVE_PRIOR) as Sum1
from diff_policy as ak)
union
(select "EXPIRED_TODAY" as Typ2, 
sum(wy.EXPIRED_TODAY) as SUM2,
"EXPIRED_PRIOR" as Type3, 
sum(wy.EXPIRED_PRIOR) as Sum3
from diff_policy as wy)
;
quit;
&lt;/LI-CODE&gt;
&lt;P&gt;My data:&lt;/P&gt;
&lt;TABLE border="1" width="100.00000000000001%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="34.73132372214941%" height="30px"&gt;Type&lt;/TD&gt;
&lt;TD width="15.59633027522936%" height="30px"&gt;Sum&lt;/TD&gt;
&lt;TD width="34.07601572739188%" height="30px"&gt;Type1&lt;/TD&gt;
&lt;TD width="15.59633027522936%" height="30px"&gt;Sum1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="34.73132372214941%" height="30px"&gt;ACTIVE_TODAY&lt;/TD&gt;
&lt;TD width="15.59633027522936%" height="30px"&gt;122265&lt;/TD&gt;
&lt;TD width="34.07601572739188%" height="30px"&gt;ACTIVE_PRIOR&lt;/TD&gt;
&lt;TD width="15.59633027522936%" height="30px"&gt;122641&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="34.73132372214941%" height="30px"&gt;EXPIRED_TODAY&lt;/TD&gt;
&lt;TD width="15.59633027522936%" height="30px"&gt;6790&lt;/TD&gt;
&lt;TD width="34.07601572739188%" height="30px"&gt;EXPIRED_PRIOR&lt;/TD&gt;
&lt;TD width="15.59633027522936%" height="30px"&gt;1744&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When i run below code:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc sgplot data=graphbar;
vbarparm category=Type response=Sum / discreteoffset=-0.17 barwidth=0.3;
vbarparm category=Type1 response=Sum1 / discreteoffset=0.17 barwidth=0.3;
vbarparm category=Type2 response=Sum2 / discreteoffset=0.17 barwidth=0.3;
vbarparm category=Type3 response=Sum3 / discreteoffset=0.17 barwidth=0.3;

run;&lt;/LI-CODE&gt;
&lt;P&gt;log shows that Type/Sum variable not found. How to change data and proc sgplot to get some like a below :&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Gieorgie_0-1636096677207.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65427i68D826DC49E6CBB4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Gieorgie_0-1636096677207.png" alt="Gieorgie_0-1636096677207.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2021 07:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-bar-graph-problem-with-set-up/m-p/778668#M247890</guid>
      <dc:creator>Gieorgie</dc:creator>
      <dc:date>2021-11-05T07:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: multiple bar graph problem with set up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-bar-graph-problem-with-set-up/m-p/778673#M247894</link>
      <description>&lt;P&gt;Please post the LOG of both the Proc SQL and the Proc SGplot code. First, you say you are getting an error but you have 8 possible variables to have problems with and don't specify which one. Second the SQL code you show creates at least one variable, TYP2, that is not used in the Sgplot where you use Type2.&lt;/P&gt;
&lt;P&gt;So you may have more than one typo involved and can't guess exactly which error might be involved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally , your posted "data" shows Expired_today as a value for Type, not Typ2 (or Type2). So your SQL seems not to have created the data you think it did.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2021 08:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-bar-graph-problem-with-set-up/m-p/778673#M247894</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-05T08:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: multiple bar graph problem with set up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-bar-graph-problem-with-set-up/m-p/778676#M247896</link>
      <description>&lt;P&gt;Hello Thanks for your answear . Sorry for the typo&lt;/P&gt;
&lt;P&gt;This is log from sgplot :&lt;/P&gt;
&lt;HR /&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;28 proc sgplot data=graphbar;&lt;BR /&gt;29 vbarparm category=Type response=Sum / discreteoffset=-0.17 barwidth=0.3;&lt;BR /&gt;30 vbarparm category=Type1 response=Sum1 / discreteoffset=0.17 barwidth=0.3;&lt;BR /&gt;31 vbarparm category=Type2 response=Sum2 / discreteoffset=0.17 barwidth=0.3;&lt;BR /&gt;ERROR: Variable TYPE2 not found.&lt;BR /&gt;ERROR: Variable SUM2 not found.&lt;BR /&gt;32 vbarparm category=Type3 response=Sum3 / discreteoffset=0.17 barwidth=0.3;&lt;BR /&gt;ERROR: Variable TYPE3 not found.&lt;BR /&gt;ERROR: Variable SUM3 not found.&lt;BR /&gt;33 &lt;BR /&gt;34 run;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is for my proc sql :&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;28 proc sql ;&lt;BR /&gt;29 create table graphbar as&lt;BR /&gt;30 select *&lt;BR /&gt;31 from&lt;BR /&gt;32 (select "ACTIVE_TODAY" as Type,&lt;BR /&gt;33 sum(ak.ACTIVE_TODAY) as Sum,&lt;BR /&gt;34 "ACTIVE_PRIOR" as Type1,&lt;BR /&gt;35 sum(ak.ACTIVE_PRIOR) as Sum1&lt;BR /&gt;36 from diff_policy as ak)&lt;BR /&gt;37 union&lt;BR /&gt;38 (select "EXPIRED_TODAY" as Type2,&lt;BR /&gt;39 sum(wy.EXPIRED_TODAY) as SUM2,&lt;BR /&gt;40 "EXPIRED_PRIOR" as Type3,&lt;BR /&gt;41 sum(wy.EXPIRED_PRIOR) as Sum3&lt;BR /&gt;42 from diff_policy as wy)&lt;BR /&gt;43 ;&lt;BR /&gt;NOTE: Table WORK.GRAPHBAR created, with 2 rows and 4 columns.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;44 quit;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2021 08:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-bar-graph-problem-with-set-up/m-p/778676#M247896</guid>
      <dc:creator>Gieorgie</dc:creator>
      <dc:date>2021-11-05T08:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: multiple bar graph problem with set up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-bar-graph-problem-with-set-up/m-p/778681#M247900</link>
      <description>&lt;P&gt;Note your log where it says:&lt;/P&gt;
&lt;PRE&gt;NOTE: Table WORK.GRAPHBAR created, with 2 rows and 4 columns.&lt;/PRE&gt;
&lt;P&gt;4 columns = 4 variables. Your SGPLOT code lists 8 variables.&lt;/P&gt;
&lt;P&gt;You need to check the results of your SQL, it does not have the variables you think it does because it has "type2" as type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think that your SQL needs OUTER Union CORR&lt;/P&gt;
&lt;PRE&gt;proc sql ;
create table graphbar as
select *
from
(select "ACTIVE_TODAY" as Type,
sum(ak.ACTIVE_TODAY) as Sum,
"ACTIVE_PRIOR" as Type1,
sum(ak.ACTIVE_PRIOR) as Sum1
from diff_policy as ak)
outer union corr
(select "EXPIRED_TODAY" as Type2,
sum(wy.EXPIRED_TODAY) as SUM2,
"EXPIRED_PRIOR" as Type3,
sum(wy.EXPIRED_PRIOR) as Sum3
from diff_policy as wy)
;&lt;/PRE&gt;
&lt;P&gt;UNION default behavior is to have the values of the first, second etc column in each of the query bits stack. CORR aligns like name variables, the OUTER means that you have variables that don't align, otherwise Corr would only keep the matched names, which your code doesn't have at all.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2021 09:27:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-bar-graph-problem-with-set-up/m-p/778681#M247900</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-05T09:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: multiple bar graph problem with set up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-bar-graph-problem-with-set-up/m-p/778685#M247901</link>
      <description>&lt;P&gt;yeah , its look much better, thanks ! its look now like this. &lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Gieorgie_0-1636104687653.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65431iB10269A537363A58/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Gieorgie_0-1636104687653.png" alt="Gieorgie_0-1636104687653.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But maybe is there a chance that he can combine 4 bars into two bars so that Active and prior will be one bar showing the differences&lt;/P&gt;
&lt;P&gt;For example like a below : Active and Prior might be look like a "2006"&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Gieorgie_1-1636104909561.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65432i6D761820CFBF5C14/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Gieorgie_1-1636104909561.png" alt="Gieorgie_1-1636104909561.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2021 09:35:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-bar-graph-problem-with-set-up/m-p/778685#M247901</guid>
      <dc:creator>Gieorgie</dc:creator>
      <dc:date>2021-11-05T09:35:35Z</dc:date>
    </item>
  </channel>
</rss>

