<?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 Bar charts in SAS Visual Analytics</title>
    <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Bar-charts/m-p/610875#M13370</link>
    <description>&lt;P&gt;Does anyone know the code to do a chart like this, in SAS 9.4? Where the survey questions are on the y axis and the survey scores are on the x-axis, divided up in the legend between pre and post, plus standard deviations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See attached photo example&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Dec 2019 00:55:07 GMT</pubDate>
    <dc:creator>stancemcgraw</dc:creator>
    <dc:date>2019-12-11T00:55:07Z</dc:date>
    <item>
      <title>Bar charts</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Bar-charts/m-p/610875#M13370</link>
      <description>&lt;P&gt;Does anyone know the code to do a chart like this, in SAS 9.4? Where the survey questions are on the y axis and the survey scores are on the x-axis, divided up in the legend between pre and post, plus standard deviations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See attached photo example&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 00:55:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Bar-charts/m-p/610875#M13370</guid>
      <dc:creator>stancemcgraw</dc:creator>
      <dc:date>2019-12-11T00:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: Bar charts</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Bar-charts/m-p/610967#M13371</link>
      <description>&lt;P&gt;SGPLOT can do this, but the bar segments are side by side (GROUPDISPLAY=CLUSTER)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the stacked bar then you need to calculate the values up front and use VBARPARM together with the HIGHLOW plot statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example ussing SASHELP.CARS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
 * generate test data
 */
data cars;
  set sashelp.cars;
  where
    origin in ("Asia", "USA")
    and not (type = "Hybrid")
  ;
  /*
   * choose which var to use
   */
  value = horsepower;
  format value comma12.;
run;

/*
 * what you get for free
 */
ods graphics / width=1200 height=900;
proc sgplot data=cars;
  vbar type /
    group=origin
    response=value
    stat=mean
    limits=both
    limitstat=stddev
    groupdisplay=cluster
    seglabel
  ;
run;

/*
 * calculate mean and std
 */
proc  sql;
  create table cars_limits as
  select
    type
    , origin
    , mean(value) as mean_value format=comma12.
    , std(value) as std_value format=comma12.
  from
    cars
  group by
      type
    , origin
  order by
    type
    , origin
  ;
quit;

/*
 * compute values used with highlow stmt
 */
data cars_limits2;
  set cars_limits;
  by type;
  mean_value2 = lag1(mean_value);
  if origin = "Asia" then do;
    a_ll = mean_value - (1 * std_value);
    a_ul = mean_value + (1 * std_value);
  end;
  if origin = "USA" then do;
    b_ll = mean_value2 + ( mean_value - (1 * std_value) );
    b_ul = mean_value2 + ( mean_value + (1 * std_value) );
  end;
run;
   
/*
 * create graph
 */ 
proc sgplot data=cars_limits2;
  vbarparm category=type response=mean_value / group=origin groupdisplay=stack seglabel;
  highlow x=type low=a_ll high=a_ul / group=origin lowcap=serif highcap=serif lineattrs=(color=cx000000);
  highlow x=type low=b_ll high=b_ul / group=origin lowcap=serif highcap=serif lineattrs=(color=cx000000);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Dec 2019 12:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Bar-charts/m-p/610967#M13371</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2019-12-11T12:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Bar charts</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Bar-charts/m-p/610968#M13372</link>
      <description>&lt;P&gt;Sorry I missed the point that this is all to be in Visual Analytics.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have a look here&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Visual-Analytics/Plot-of-Standard-Deviation-in-SAS-VA-Report-Designer/td-p/345167" target="_blank"&gt;https://communities.sas.com/t5/SAS-Visual-Analytics/Plot-of-Standard-Deviation-in-SAS-VA-Report-Designer/td-p/345167&lt;/A&gt;&amp;nbsp;it is not a stacked bar chart, but might give you starting point.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 13:17:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Bar-charts/m-p/610968#M13372</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2019-12-11T13:17:19Z</dc:date>
    </item>
  </channel>
</rss>

