<?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 graph with proc gchart in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/837937#M36204</link>
    <description>Making a WAG you can remove the WEIGHT statement from the code and it should work for you.&lt;BR /&gt;The summary data already had counts, it appears you're using raw data. But that's a guess - I can't see your data, variables or understand it's structure so I can only work off what's been shown.</description>
    <pubDate>Tue, 11 Oct 2022 20:26:05 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-10-11T20:26:05Z</dc:date>
    <item>
      <title>Bar graph with proc gchart</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/837885#M36196</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to do a graph with my data : a table with cancer (4 types) and sexe (male or female), 1540 patients similar to this example :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Set the graphics environment */&lt;/P&gt;&lt;P&gt;goptions reset=all cback=white border htitle=&lt;STRONG&gt;12&lt;/STRONG&gt;pt htext=&lt;STRONG&gt;10&lt;/STRONG&gt;pt;&lt;/P&gt;&lt;P&gt;/* Create sample data */&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input midpnt category $ count;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; cat1&amp;nbsp; 60&lt;/P&gt;&lt;P&gt;1&amp;nbsp; cat2&amp;nbsp; 40&lt;/P&gt;&lt;P&gt;2&amp;nbsp; cat1&amp;nbsp; 30&lt;/P&gt;&lt;P&gt;2&amp;nbsp; cat2&amp;nbsp; 70&lt;/P&gt;&lt;P&gt;3&amp;nbsp; cat1&amp;nbsp; 80&lt;/P&gt;&lt;P&gt;3&amp;nbsp; cat2&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;title1 'Subgroups for Each Midpoint Total 100%' ;&amp;nbsp;&amp;nbsp; /* Define a title for the graph */&lt;/P&gt;&lt;P&gt;axis1 label=none value=none;&amp;nbsp; /* Suppress the group axis label and values */&lt;/P&gt;&lt;P&gt;axis2 label=(angle=&lt;STRONG&gt;90&lt;/STRONG&gt; 'Percent') ;&amp;nbsp; /* Angle the label for the response axis */&lt;/P&gt;&lt;P&gt;legend1 label=('Category') frame ;&amp;nbsp; /* Define legend characteristics */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;gchart&lt;/STRONG&gt; data=test;&lt;/P&gt;&lt;P&gt;vbar midpnt / discrete subgroup=category&lt;/P&gt;&lt;P&gt;group=midpnt g100 nozero&lt;/P&gt;&lt;P&gt;freq=count type=percent /* ne pas mettre l’option freq si on a une table déjà prête*/&lt;/P&gt;&lt;P&gt;inside=percent width=&lt;STRONG&gt;20&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;gaxis=axis1 raxis=axis2&lt;/P&gt;&lt;P&gt;legend=legend1;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Nathalie1_1-1665505032264.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76092iB84AB5E82CC3D20A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Nathalie1_1-1665505032264.png" alt="Nathalie1_1-1665505032264.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try with my data and I obtain the graph :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Nathalie1_0-1665504887800.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76090i735CC7D84E6059BB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Nathalie1_0-1665504887800.png" alt="Nathalie1_0-1665504887800.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Can you help me ?&lt;/P&gt;&lt;P&gt;Here is my code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;title1 'Subgroups for Each Midpoint Total 100%' ; /* Define a title for the graph */&lt;BR /&gt;axis1 label=none value=none; /* Suppress the group axis label and values */&lt;BR /&gt;axis2 label=(angle=90 'Percent') ; /* Angle the label for the response axis */&lt;BR /&gt;legend1 label=('Category') frame ; /* Define legend characteristics */&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc gchart data=denis.fusion;&lt;BR /&gt;where sexe ne "NA";&lt;BR /&gt;vbar cancer/ discrete subgroup=sexe&lt;BR /&gt;group=cancer g100&lt;BR /&gt;inside=percent width=20&lt;BR /&gt;gaxis=axis1 raxis=axis2&lt;BR /&gt;legend=legend1;&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;&lt;P&gt;Nathalie&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 16:19:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/837885#M36196</guid>
      <dc:creator>Nathalie1</dc:creator>
      <dc:date>2022-10-11T16:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: Bar graph with proc gchart</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/837893#M36197</link>
      <description>&lt;P&gt;SGPLOT is a better option these days.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   input midpnt category $ count;
   datalines;
1  cat1  60
1  cat2  40
2  cat1  30
2  cat2  70
3  cat1  80
3  cat2  20
;
run;

*calculate percentages for stacked 100% bar chart;
proc freq data=test noprint;
table midpnt*category / out=want outpct ;
weight count;
run;

*convert to percent for easier display;
data want;
set want;
pct_row = pct_row/100;
format pct_row percent12.1;
run;

*graph data;
title 'My Custom Graph Title';
proc sgplot data=want;
vbarparm category=midpnt response=pct_row / group=category groupdisplay=stack seglabel;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;See options here for customizing the graphics further&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n0mc5dtithid5mn13c54dlgaceq3.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n0mc5dtithid5mn13c54dlgaceq3.htm&lt;/A&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;</description>
      <pubDate>Tue, 11 Oct 2022 17:29:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/837893#M36197</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-11T17:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: Bar graph with proc gchart</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/837916#M36199</link>
      <description>&lt;P&gt;Thank you for your response, but I can't run the program because my table of data has no count. I had put an example that I want adapt to my data.&lt;/P&gt;&lt;P&gt;If I run your code with my data, I obtain :&lt;/P&gt;&lt;P&gt;proc freq data= denis.fusion noprint;&lt;BR /&gt;table cancer * sexe /out = want outpct;&lt;BR /&gt;weight count;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 proc freq data= denis.fusion noprint;&lt;BR /&gt;2 table cancer * sexe /out = want outpct;&lt;BR /&gt;3 weight count;&lt;BR /&gt;ERROR: Variable COUNT not found.&lt;BR /&gt;4 run;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 18:45:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/837916#M36199</guid>
      <dc:creator>Nathalie1</dc:creator>
      <dc:date>2022-10-11T18:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: Bar graph with proc gchart</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/837928#M36200</link>
      <description>I used the example data set provided. It looks like the Count variable in your example data set does not exist in your data set or has a different name?&lt;BR /&gt;You should update the code to account for that variable name change or difference.&lt;BR /&gt;&lt;BR /&gt;3 weight count;&lt;BR /&gt;ERROR: Variable COUNT not found.&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Oct 2022 19:14:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/837928#M36200</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-11T19:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Bar graph with proc gchart</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/837930#M36201</link>
      <description>&lt;P&gt;Since your Yaxis is going to 600 percent then your data is incorrect for the type of graph you are attempting.&lt;/P&gt;
&lt;P&gt;So share the actual data you are attempting to graph, not a made up example with different variables with different ranges of values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;/&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 19:38:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/837930#M36201</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-11T19:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: Bar graph with proc gchart</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/837937#M36204</link>
      <description>Making a WAG you can remove the WEIGHT statement from the code and it should work for you.&lt;BR /&gt;The summary data already had counts, it appears you're using raw data. But that's a guess - I can't see your data, variables or understand it's structure so I can only work off what's been shown.</description>
      <pubDate>Tue, 11 Oct 2022 20:26:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/837937#M36204</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-11T20:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: Bar graph with proc gchart</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/838820#M36264</link>
      <description>&lt;P&gt;Thank you for your response.&lt;/P&gt;&lt;P&gt;I try to do the graph in my first post.&lt;/P&gt;&lt;P&gt;I give you my table of data with 3 variables id, sexe and cancer (4 types).&lt;/P&gt;&lt;P&gt;For sexe, NA is unknown.&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;&lt;P&gt;I work with SAS 9.4.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2022 14:32:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/838820#M36264</guid>
      <dc:creator>Nathalie1</dc:creator>
      <dc:date>2022-10-15T14:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Bar graph with proc gchart</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/838884#M36280</link>
      <description>&lt;P&gt;Removing count and updating the variable names worked for me...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
*calculate percentages for stacked 100% bar chart;
proc freq data=essai noprint;
where sexe ne 'NA';
table cancer*sexe / out=want outpct ;
run;

*convert to percent for easier display;
data want;
set want;
pct_row = pct_row/100;
format pct_row percent12.1;
run;

*graph data;
title 'My Custom Graph Title';
proc sgplot data=want;
vbarparm category=cancer response=pct_row / group=sexe groupdisplay=stack seglabel;
yaxis '';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 16 Oct 2022 23:26:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/838884#M36280</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-16T23:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: Bar graph with proc gchart</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/838921#M36290</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much. It is OK.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 09:41:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Bar-graph-with-proc-gchart/m-p/838921#M36290</guid>
      <dc:creator>Nathalie1</dc:creator>
      <dc:date>2022-10-17T09:41:02Z</dc:date>
    </item>
  </channel>
</rss>

