<?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: How would I be able to output a totals column using proc freq when counting? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-would-I-be-able-to-output-a-totals-column-using-proc-freq/m-p/807140#M318152</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines dsd dlm=",";
length gender level $10;
 input gender $ level $;
datalines;
female, one
male, one
male, one
male, two
female, one
female, one
female, two
female, two
male, two
male, two
female, one
refused, two
female, two
male, two
; 
run;
ods select none;
ods output CrossTabFreqs=count ;
proc freq data=have;
 table gender*level ;
run;
ods select all;

data have; set count;
length count_percent $10;
 count_percent=strip(put(Frequency, 32.)) || " (" || strip(put(percent, 32.2)) || ")";
 if missing(level) then level='Total';
 if not missing(gender);
run;
proc sort; by gender; run;

proc transpose data=have  out=have2 (drop= _NAME_);
 by gender;
 id level;
 var count_percent;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 11 Apr 2022 11:54:56 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2022-04-11T11:54:56Z</dc:date>
    <item>
      <title>How would I be able to output a totals column using proc freq when counting?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-would-I-be-able-to-output-a-totals-column-using-proc-freq/m-p/807090#M318121</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines dsd dlm=",";
length gender level $10;
	input gender $ level $;
datalines;
female, one
male, one
male, one
male, two
female, one
female, one
female, two
female, two
male, two
male, two
female, one
refused, two
female, two
male, two
; 
run;

proc freq data=have;
	table gender*level/ out=count;
run;

data have; set count;
length count_percent $10;
	count_percent=strip(put(count, 32.)) || " (" || strip(put(percent, 32.2)) || ")";
drop count percent;
run;
proc sort; by gender; run;

proc transpose data=have  out=have2 (drop= _NAME_);
	by gender;
	id level;
	var count_percent;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to add a totals column to this output dataset:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Hello_there_0-1649650685561.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70289i5F9D7CECE572E327/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Hello_there_0-1649650685561.png" alt="Hello_there_0-1649650685561.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;so that it says after gender, one, two, it says total&lt;/P&gt;
&lt;P&gt;And there would be 7 females, 6 males, and 1 refused.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this possible in proc freq?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 04:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-would-I-be-able-to-output-a-totals-column-using-proc-freq/m-p/807090#M318121</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2022-04-11T04:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: How would I be able to output a totals column using proc freq when counting?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-would-I-be-able-to-output-a-totals-column-using-proc-freq/m-p/807101#M318127</link>
      <description>&lt;P&gt;Not with proc freq, but with proc tabulate:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=have;
   class gender level;
   table gender, level*(n pctn) all;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The layout differs: count and percent are in two columns&amp;nbsp; (no, you can't combine them in proc tabulate).&lt;/P&gt;
&lt;P&gt;Looking better:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=have;
   class gender level;
   table gender= ' ', level= ' ' * (n pctn) all / box= 'Gender';
   keylabel n= ' ' pctn= ' ' all= 'total';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Apr 2022 06:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-would-I-be-able-to-output-a-totals-column-using-proc-freq/m-p/807101#M318127</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-04-11T06:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: How would I be able to output a totals column using proc freq when counting?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-would-I-be-able-to-output-a-totals-column-using-proc-freq/m-p/807140#M318152</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines dsd dlm=",";
length gender level $10;
 input gender $ level $;
datalines;
female, one
male, one
male, one
male, two
female, one
female, one
female, two
female, two
male, two
male, two
female, one
refused, two
female, two
male, two
; 
run;
ods select none;
ods output CrossTabFreqs=count ;
proc freq data=have;
 table gender*level ;
run;
ods select all;

data have; set count;
length count_percent $10;
 count_percent=strip(put(Frequency, 32.)) || " (" || strip(put(percent, 32.2)) || ")";
 if missing(level) then level='Total';
 if not missing(gender);
run;
proc sort; by gender; run;

proc transpose data=have  out=have2 (drop= _NAME_);
 by gender;
 id level;
 var count_percent;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Apr 2022 11:54:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-would-I-be-able-to-output-a-totals-column-using-proc-freq/m-p/807140#M318152</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-04-11T11:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: How would I be able to output a totals column using proc freq when counting?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-would-I-be-able-to-output-a-totals-column-using-proc-freq/m-p/807260#M318237</link>
      <description>Thank you!</description>
      <pubDate>Tue, 12 Apr 2022 00:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-would-I-be-able-to-output-a-totals-column-using-proc-freq/m-p/807260#M318237</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2022-04-12T00:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: How would I be able to output a totals column using proc freq when counting?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-would-I-be-able-to-output-a-totals-column-using-proc-freq/m-p/807261#M318238</link>
      <description>Perfect, thanks!</description>
      <pubDate>Tue, 12 Apr 2022 00:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-would-I-be-able-to-output-a-totals-column-using-proc-freq/m-p/807261#M318238</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2022-04-12T00:11:57Z</dc:date>
    </item>
  </channel>
</rss>

