<?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: Proc gchart &amp;amp; proc freq output out dataset (need row pct &amp;amp; total pct in graph) in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Proc-gchart-amp-proc-freq-output-out-dataset-need-row-pct-amp/m-p/239142#M8688</link>
    <description>&lt;P&gt;Hello Anna,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could create a more suitable dataset BONUS from&amp;nbsp;the CrossTabFreqs ODS output dataset and modify the PROC GCHART step accordingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods output CrossTabFreqs=ctf;
proc freq data=heart_newv ;
table age*smoking;
where exam = 1 AND age ne . AND smoking ne .;
format smoking smoking_f. age age_f.;
run;
ods output close;

data bonus;
length agegrp $7;
set ctf;
where smoking = 1;
pct=coalesce(rowpercent, percent); /* get percentages into one variable */
overall=missing(age); /* overall=1 for the 'Overall' group, 0 otherwise */
if overall then agegrp='Overall';
else agegrp=put(age, age_f.);
keep agegrp overall pct;
run;

goptions reset=all;
PATTERN1 color=PARP;
PATTERN2 color=MORP;
proc gchart data=bonus;
title 'Smoking Prevalence at exam 1 by age group and overall';
vbar agegrp / sumvar=pct subgroup=overall nolegend space=3 raxis=axis1 maxis=axis2;
axis1 label = (a=90 'Percentage Smoking')order=0 to 100 by 10;
axis2 label = none;
run;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 14 Dec 2015 13:35:04 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2015-12-14T13:35:04Z</dc:date>
    <item>
      <title>Proc gchart &amp; proc freq output out dataset (need row pct &amp; total pct in graph)</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-gchart-amp-proc-freq-output-out-dataset-need-row-pct-amp/m-p/239064#M8687</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I am in need of some help with getting information from outpct out= from a proc freq into proc gchart.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have mangaged to get the PCT_ROW into the gchart, but am having trouble figuring out how to output &lt;STRONG&gt;total percents&lt;/STRONG&gt; from the 2way freq table to my output data set, &lt;STRONG&gt;in addition to &lt;/STRONG&gt;the &lt;STRONG&gt;row percents&lt;/STRONG&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to create a chart that looks like the attached picture, but all I can get is the first 3 of the 4 bars (see second attached picture).&lt;/P&gt;&lt;P&gt;I've also put my proc freq output, just for reference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code that is successfully giving me the output dataset and the three bars...&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
value age_f
	30-40='30-40'
	41-55='41-55'
	56-high='56+';
run;

proc freq data=heart_newv ;
table age*smoking / OUTPCT out = bonus;
where exam = 1 AND age ne . AND smoking ne .;
format smoking smoking_f. age age_f.;
run;

goptions reset=all;
*ODS RTF FILE='C:\Users\Anna\Documents\SAS\GRAPH.RTF';
PATTERN1 color=PARP;
PATTERN2 color=MORP;
proc gchart data=bonus;
title 'Smoking Prevalence at exam 1 by age group and overall';
vbar smoking / group=age discrete SUMVAR=PCT_ROW space=3 gspace=5 raxis=axis1 maxis=axis2 gaxis=axis3;
where age ne . AND smoking ne . AND smoking = 1;
axis1 label = (a=90 'Percentage Smoking')order=0 to 100 by 10;
axis2 label = none;
axis3 label = none;
format age age_f. ;
run;
quit;
*ODS RTF CLOSE;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thank you kindly to whomever can help with this! I just can't seem to find an easy way to get that overall percent there!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12136i46016DC5D6F9A320/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="chart_with_missing_overall.png" title="chart_with_missing_overall.png" /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12137iAE9B37A347F43FDE/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Graphs.gif" title="Graphs.gif" /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12138i9AD31E9CE98AB59F/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="proc freq output.JPG" title="proc freq output.JPG" /&gt;</description>
      <pubDate>Sun, 13 Dec 2015 18:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-gchart-amp-proc-freq-output-out-dataset-need-row-pct-amp/m-p/239064#M8687</guid>
      <dc:creator>bama8</dc:creator>
      <dc:date>2015-12-13T18:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Proc gchart &amp; proc freq output out dataset (need row pct &amp; total pct in graph)</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-gchart-amp-proc-freq-output-out-dataset-need-row-pct-amp/m-p/239142#M8688</link>
      <description>&lt;P&gt;Hello Anna,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could create a more suitable dataset BONUS from&amp;nbsp;the CrossTabFreqs ODS output dataset and modify the PROC GCHART step accordingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods output CrossTabFreqs=ctf;
proc freq data=heart_newv ;
table age*smoking;
where exam = 1 AND age ne . AND smoking ne .;
format smoking smoking_f. age age_f.;
run;
ods output close;

data bonus;
length agegrp $7;
set ctf;
where smoking = 1;
pct=coalesce(rowpercent, percent); /* get percentages into one variable */
overall=missing(age); /* overall=1 for the 'Overall' group, 0 otherwise */
if overall then agegrp='Overall';
else agegrp=put(age, age_f.);
keep agegrp overall pct;
run;

goptions reset=all;
PATTERN1 color=PARP;
PATTERN2 color=MORP;
proc gchart data=bonus;
title 'Smoking Prevalence at exam 1 by age group and overall';
vbar agegrp / sumvar=pct subgroup=overall nolegend space=3 raxis=axis1 maxis=axis2;
axis1 label = (a=90 'Percentage Smoking')order=0 to 100 by 10;
axis2 label = none;
run;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Dec 2015 13:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-gchart-amp-proc-freq-output-out-dataset-need-row-pct-amp/m-p/239142#M8688</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-12-14T13:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Proc gchart &amp; proc freq output out dataset (need row pct &amp; total pct in graph)</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Proc-gchart-amp-proc-freq-output-out-dataset-need-row-pct-amp/m-p/239210#M8690</link>
      <description>&lt;P&gt;Thank you FreelanceReinhard for your speedy reply! This will work perfectly!&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2015 18:06:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Proc-gchart-amp-proc-freq-output-out-dataset-need-row-pct-amp/m-p/239210#M8690</guid>
      <dc:creator>bama8</dc:creator>
      <dc:date>2015-12-14T18:06:21Z</dc:date>
    </item>
  </channel>
</rss>

