<?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: bar chart with error bars in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500246#M17049</link>
    <description>&lt;P&gt;Ok. Here is my data. Just like you said, I run this code;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc means data=btnret mean n lclm uclm stackods;&lt;BR /&gt;class month;&lt;BR /&gt;var CO2flux;&lt;BR /&gt;ods output summary=classMean;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sgplot data=classMean;&lt;BR /&gt;vbarparm category=month response=mean /&lt;BR /&gt;limitlower=lclm&lt;BR /&gt;limitupper=uclm;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I want to have the same graph for 3 different spacing ; 0.5 , 1&amp;nbsp; , 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you, I really appreciate it .&lt;/P&gt;</description>
    <pubDate>Mon, 01 Oct 2018 00:37:08 GMT</pubDate>
    <dc:creator>smorkoc</dc:creator>
    <dc:date>2018-10-01T00:37:08Z</dc:date>
    <item>
      <title>bar chart with error bars</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500222#M17045</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I was trying to create a barchart with error bars, my x-axis= month, y-axis=CO2flux.. Here is my code;&lt;/P&gt;&lt;P&gt;proc sort data=mydata.butner_new1 out=btnret;&lt;BR /&gt;by spacing;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc means data=btnret nway mean clm noprint;&lt;BR /&gt;by spacing;&lt;BR /&gt;class month;&lt;BR /&gt;var CO2flux;&lt;BR /&gt;output out=new mean= lclm= uclm= / autoname;&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;proc template;&lt;BR /&gt;define statgraph barchart;&lt;BR /&gt;begingraph;&lt;BR /&gt;entrytitle 'Bar Chart with Error Bars';&lt;BR /&gt;layout gridded / border=false;&lt;BR /&gt;layout datalattice columnvar=spacing / headerlabeldisplay=value cellwidthmin=50&lt;BR /&gt;columnheaders=bottom border=false columndatarange=union&lt;BR /&gt;columnaxisopts=(display=(line tickvalues))&lt;BR /&gt;rowaxisopts=(offsetmin=0 linearopts=(tickvaluepriority=true)&lt;BR /&gt;label='Mean CO2flux' griddisplay=on);&lt;BR /&gt;layout prototype / walldisplay=(fill);&lt;BR /&gt;barchart x=month y=CO2flux_mean / group=spacing barlabel=true&lt;BR /&gt;name='bar' outlineattrs=(color=black);&lt;BR /&gt;scatterplot x=month y=CO2flux_mean / group=spacing yerrorlower=CO2flux_lclm&lt;BR /&gt;yerrorupper=CO2flux_uclm&lt;BR /&gt;markerattrs=(size=0) name='scatter'&lt;BR /&gt;errorbarattrs=(thickness=2) datatransparency=0.6;&lt;BR /&gt;endlayout;&lt;BR /&gt;endlayout;&lt;BR /&gt;endlayout;&lt;BR /&gt;endgraph;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sgrender data=new template=barchart;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I got this result added as file, but it seems I did something wrong, the error bars are too big, how can fix this? Thank you.&lt;/P&gt;</description>
      <pubDate>Sun, 30 Sep 2018 22:08:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500222#M17045</guid>
      <dc:creator>smorkoc</dc:creator>
      <dc:date>2018-09-30T22:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: bar chart with error bars</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500230#M17046</link>
      <description>&lt;P&gt;Are you sure they're wrong? Is there any specific reason you're using PROC TEMPLATE and not just SGPLOT?&lt;/P&gt;
&lt;P&gt;HBARPARM supports confidence limits.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without the data to run the code,&amp;nbsp;this is a harder one to say what's going wrong. I'll move it to the graphics forum and hopefully one of the graphing gurus can assist. I have an alternate solution below. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; proc means data=sashelp.class  mean n lclm uclm stackods;
 class age;
 var height;
 ods output summary=classMean;
 run;
 
 
proc sgplot data=classMean;
 vbarparm category=age response=mean /
    limitlower=lclm
    limitupper=uclm;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/123873"&gt;@smorkoc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;BR /&gt;I was trying to create a barchart with error bars, my x-axis= month, y-axis=CO2flux.. Here is my code;&lt;/P&gt;
&lt;P&gt;proc sort data=mydata.butner_new1 out=btnret;&lt;BR /&gt;by spacing;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc means data=btnret nway mean clm noprint;&lt;BR /&gt;by spacing;&lt;BR /&gt;class month;&lt;BR /&gt;var CO2flux;&lt;BR /&gt;output out=new mean= lclm= uclm= / autoname;&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;proc template;&lt;BR /&gt;define statgraph barchart;&lt;BR /&gt;begingraph;&lt;BR /&gt;entrytitle 'Bar Chart with Error Bars';&lt;BR /&gt;layout gridded / border=false;&lt;BR /&gt;layout datalattice columnvar=spacing / headerlabeldisplay=value cellwidthmin=50&lt;BR /&gt;columnheaders=bottom border=false columndatarange=union&lt;BR /&gt;columnaxisopts=(display=(line tickvalues))&lt;BR /&gt;rowaxisopts=(offsetmin=0 linearopts=(tickvaluepriority=true)&lt;BR /&gt;label='Mean CO2flux' griddisplay=on);&lt;BR /&gt;layout prototype / walldisplay=(fill);&lt;BR /&gt;barchart x=month y=CO2flux_mean / group=spacing barlabel=true&lt;BR /&gt;name='bar' outlineattrs=(color=black);&lt;BR /&gt;scatterplot x=month y=CO2flux_mean / group=spacing yerrorlower=CO2flux_lclm&lt;BR /&gt;yerrorupper=CO2flux_uclm&lt;BR /&gt;markerattrs=(size=0) name='scatter'&lt;BR /&gt;errorbarattrs=(thickness=2) datatransparency=0.6;&lt;BR /&gt;endlayout;&lt;BR /&gt;endlayout;&lt;BR /&gt;endlayout;&lt;BR /&gt;endgraph;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sgrender data=new template=barchart;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and I got this result added as file, but it seems I did something wrong, the error bars are too big, how can fix this? Thank you.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 30 Sep 2018 22:37:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500230#M17046</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-30T22:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: bar chart with error bars</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500241#M17047</link>
      <description>&lt;P&gt;Thank you so much, it worked great but I guess it shows all the spacing together. I would like to show 3 different spacing results in one graph; just like I tried to show it in my previous graph.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 30 Sep 2018 23:04:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500241#M17047</guid>
      <dc:creator>smorkoc</dc:creator>
      <dc:date>2018-09-30T23:04:06Z</dc:date>
    </item>
    <item>
      <title>Re: bar chart with error bars</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500244#M17048</link>
      <description>&lt;P&gt;Well if you post data that allows us to replicate your chart I'm willing to take a stab at it, but without data I can't run the code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general, I wouldn't recommend that as well either. You should genrealze your template code and use SGRENDER and DYNAMIC variables to point to it. It makes it easier to re-use a template but you've hardcoded variable names and such into yours.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/123873"&gt;@smorkoc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you so much, it worked great but I guess it shows all the spacing together. I would like to show 3 different spacing results in one graph; just like I tried to show it in my previous graph.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 30 Sep 2018 23:35:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500244#M17048</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-30T23:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: bar chart with error bars</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500246#M17049</link>
      <description>&lt;P&gt;Ok. Here is my data. Just like you said, I run this code;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc means data=btnret mean n lclm uclm stackods;&lt;BR /&gt;class month;&lt;BR /&gt;var CO2flux;&lt;BR /&gt;ods output summary=classMean;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sgplot data=classMean;&lt;BR /&gt;vbarparm category=month response=mean /&lt;BR /&gt;limitlower=lclm&lt;BR /&gt;limitupper=uclm;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I want to have the same graph for 3 different spacing ; 0.5 , 1&amp;nbsp; , 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you, I really appreciate it .&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 00:37:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500246#M17049</guid>
      <dc:creator>smorkoc</dc:creator>
      <dc:date>2018-10-01T00:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: bar chart with error bars</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500251#M17050</link>
      <description>&lt;P&gt;So your code is correct and as I suspected your data has those ranges in it. Your ranges are that big and includes negative, so you probably need a different way to calculate your CI, which depends on your data. &amp;nbsp;I'm assuming for example that you can't have a negative value for the CO2Flux, which you do have in your confidence intervals.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is as far as I know how to get with SGPLOT but, it shows the same graph as yours essentially when used with your data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=new;
 vbarparm category=spacing response=co2flux_mean / group=month groupdisplay=cluster
    limitlower=co2flux_lclm
    limitupper=co2flux_uclm;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/123873"&gt;@smorkoc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Ok. Here is my data. Just like you said, I run this code;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc means data=btnret mean n lclm uclm stackods;&lt;BR /&gt;class month;&lt;BR /&gt;var CO2flux;&lt;BR /&gt;ods output summary=classMean;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sgplot data=classMean;&lt;BR /&gt;vbarparm category=month response=mean /&lt;BR /&gt;limitlower=lclm&lt;BR /&gt;limitupper=uclm;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but I want to have the same graph for 3 different spacing ; 0.5 , 1&amp;nbsp; , 2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you, I really appreciate it .&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 02:28:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500251#M17050</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-01T02:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: bar chart with error bars</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500255#M17051</link>
      <description>&lt;P&gt;I'm confused a little bit. As you see , I do not have any negative number for CO2flux in my data , is&amp;nbsp; it possible to get negative numbers for CI?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 02:40:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500255#M17051</guid>
      <dc:creator>smorkoc</dc:creator>
      <dc:date>2018-10-01T02:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: bar chart with error bars</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500259#M17052</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/123873"&gt;@smorkoc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm confused a little bit. As you see , I do not have any negative number for CO2flux in my data , is&amp;nbsp; it possible to get negative numbers for CI?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes it is. Check the data in the NEW data set, you have negative values in it for the lower bound.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 02:55:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/bar-chart-with-error-bars/m-p/500259#M17052</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-01T02:55:53Z</dc:date>
    </item>
  </channel>
</rss>

