<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Bar-chart/m-p/610275#M177698</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a way to create a hbar from summary_b:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;axis1 label=none;                                                                                                                       
axis2 label=('your label') order=0 to 1 by 0.1 ;                                                                                                                                                                                                                                                                                                                                                     
title1 'Your title';                                                                                                                
                 
proc gchart data=summary_b;
	hbar Y_Cat / sumvar = PCT_SUM_Y maxis=axis1 raxis=axis2  nostats;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise, you can simplify your code:&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value ffmt
0-40='0-40'
40-80='40-80'
80-100='80-100'
;
run;

Data RawTbl_bis;
	set rawtbl;
	format Y_class ffmt.;
	Y_class = Y;
run;

proc tabulate data=RawTbl_bis out=summary_stat;
	var Y;
	class Y_class;
	tables Y_class*(Y* (sum pctsum));
	format Y ffmt.;
run;

axis1 label=none;                                                                                                                       
axis2 label=('your label') order=0 to 100 by 10 ;                                                                                                                                                                                                                                                                                                                                                     
title1 'Your title';                                                                                                                
                 
proc gchart data=summary_stat;
	hbar Y_class / sumvar = Y_pctsum_0_Y maxis=axis1 raxis=axis2 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 08 Dec 2019 16:52:45 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2019-12-08T16:52:45Z</dc:date>
    <item>
      <title>Bar chart</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bar-chart/m-p/610272#M177697</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to create bar chart of following information in table "&lt;CODE class=" language-sas"&gt;summary_b"&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;x-axis will have Y_Cat categories&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;y-axis will display&amp;nbsp;PCT_SUM_Y&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;I want also to learn how to create this bar chart from original raw data (RawTbl table)&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;thank you&lt;/CODE&gt;&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;Data RawTbl;
input ID group $ Y;
cards;
1 a 10
2 a 20
3 a 30
4 b 15
5 b 30
6 b  45
7 c 60
8 c 75
9 c 90
10 c 80
;
run;

/*chart1*/
ods graphics on;
proc freq data=RawTbl;
tables group / plots=FreqPlot(scale=Percent) out=Freq1Out; /* save Percent variable */
run;


/*chart2*/
proc format;
value ffmt
0-40='0-40'
40-80='40-80'
80-100='80-100'
;
run;

ods graphics on;
proc freq data=RawTbl;
tables Y / plots=FreqPlot(scale=Percent) out=Freq1Out; /* save Percent variable */
format Y ffmt.;
run;

/*chart3*/
PROC SQL;
	create table summary_a  as
	select put(Y,ffmt.) as Y_Cat,
          sum(Y) as Sum_Y 
	from  RawTbl
	group by calculated Y_Cat
;
QUIT;
PROC SQL;
	create table summary_b  as
	select *,
          Sum_Y/sum(Sum_Y) as PCT_SUM_Y  format=percent9.1
	from  summary_a
;
QUIT;
/*Now I want to create  bar chart of Y_Cat (x-axis) ,PCT_SUM_Y (y-axis)*/
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 08 Dec 2019 09:23:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bar-chart/m-p/610272#M177697</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-12-08T09:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: Bar chart</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bar-chart/m-p/610275#M177698</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a way to create a hbar from summary_b:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;axis1 label=none;                                                                                                                       
axis2 label=('your label') order=0 to 1 by 0.1 ;                                                                                                                                                                                                                                                                                                                                                     
title1 'Your title';                                                                                                                
                 
proc gchart data=summary_b;
	hbar Y_Cat / sumvar = PCT_SUM_Y maxis=axis1 raxis=axis2  nostats;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise, you can simplify your code:&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value ffmt
0-40='0-40'
40-80='40-80'
80-100='80-100'
;
run;

Data RawTbl_bis;
	set rawtbl;
	format Y_class ffmt.;
	Y_class = Y;
run;

proc tabulate data=RawTbl_bis out=summary_stat;
	var Y;
	class Y_class;
	tables Y_class*(Y* (sum pctsum));
	format Y ffmt.;
run;

axis1 label=none;                                                                                                                       
axis2 label=('your label') order=0 to 100 by 10 ;                                                                                                                                                                                                                                                                                                                                                     
title1 'Your title';                                                                                                                
                 
proc gchart data=summary_stat;
	hbar Y_class / sumvar = Y_pctsum_0_Y maxis=axis1 raxis=axis2 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 08 Dec 2019 16:52:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bar-chart/m-p/610275#M177698</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-12-08T16:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: Bar chart</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bar-chart/m-p/610328#M177715</link>
      <description>&lt;P&gt;Create another variable and use that in the data set as the weight. A view would also work.&amp;nbsp;&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;Data RawTbl;
input ID group $ Y;
Z = Y;
cards;
1 a 10
2 a 20
3 a 30
4 b 15
5 b 30
6 b  45
7 c 60
8 c 75
9 c 90
10 c 80
;
run;

/*chart2*/
proc format;
value ffmt
0-40='0-40'
40-80='40-80'
80-100='80-100'
;
run;

proc freq data=rawtbl;
table y / plots=freqplot (scale=percent);
weight z;
format y ffmt.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 08 Dec 2019 19:56:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bar-chart/m-p/610328#M177715</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-12-08T19:56:01Z</dc:date>
    </item>
  </channel>
</rss>

