<?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 column percentage in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/column-percentage/m-p/71412#M20622</link>
    <description>?&lt;BR /&gt;
&lt;BR /&gt;
I have used the following code to produce a table and I want the right hand column to calculate the percentage of the column based on the sum of var1, not the n value.  At the moment each row has a value of 25%.  Is there an easy way to do this?&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
input char1 $ char2 $ var1;&lt;BR /&gt;
cards;&lt;BR /&gt;
A A 10&lt;BR /&gt;
A B 15&lt;BR /&gt;
B A 20&lt;BR /&gt;
B B 05&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc tabulate data=test;&lt;BR /&gt;
class char1 char2;&lt;BR /&gt;
var var1;&lt;BR /&gt;
table char1*char2 all,(var1 colpctn);&lt;BR /&gt;
run;</description>
    <pubDate>Tue, 27 Jan 2009 09:15:58 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-01-27T09:15:58Z</dc:date>
    <item>
      <title>column percentage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/column-percentage/m-p/71412#M20622</link>
      <description>?&lt;BR /&gt;
&lt;BR /&gt;
I have used the following code to produce a table and I want the right hand column to calculate the percentage of the column based on the sum of var1, not the n value.  At the moment each row has a value of 25%.  Is there an easy way to do this?&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
input char1 $ char2 $ var1;&lt;BR /&gt;
cards;&lt;BR /&gt;
A A 10&lt;BR /&gt;
A B 15&lt;BR /&gt;
B A 20&lt;BR /&gt;
B B 05&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc tabulate data=test;&lt;BR /&gt;
class char1 char2;&lt;BR /&gt;
var var1;&lt;BR /&gt;
table char1*char2 all,(var1 colpctn);&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 27 Jan 2009 09:15:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/column-percentage/m-p/71412#M20622</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-27T09:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: column percentage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/column-percentage/m-p/71413#M20623</link>
      <description>I've replaced the tabulate with a freq, which gives me the percentages, but the ods output isn't working to get these values in a table so that I can work with them??&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
input char1 $ char2 $ var1;&lt;BR /&gt;
cards;&lt;BR /&gt;
A A 10&lt;BR /&gt;
A B 15&lt;BR /&gt;
B A 20&lt;BR /&gt;
B B 05&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data test2;&lt;BR /&gt;
set test;&lt;BR /&gt;
char3=compress(char1||char2);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc freq data=test2;&lt;BR /&gt;
tables char3 ;&lt;BR /&gt;
weight var1;&lt;BR /&gt;
ods output table=test3;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 27 Jan 2009 09:37:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/column-percentage/m-p/71413#M20623</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-27T09:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: column percentage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/column-percentage/m-p/71414#M20624</link>
      <description>have you tried COLPCTSUM instead of COLPCTN&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
      <pubDate>Tue, 27 Jan 2009 12:12:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/column-percentage/m-p/71414#M20624</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-27T12:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: column percentage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/column-percentage/m-p/71415#M20625</link>
      <description>Hi:&lt;BR /&gt;
  Also, the syntax for creating an output data set from Proc Freq is wrong. To create an output dataset use one of these 2 methods (not both):&lt;BR /&gt;
1) use Proc FREQ syntax&lt;BR /&gt;
2) use ODS syntax.&lt;BR /&gt;
&lt;BR /&gt;
If you use ODS syntax, then the ODS output statement must PRECEDE the Proc Freq -and- you must have the right output object &amp;lt;object&amp;gt; for the procedure:&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods trace on / label;&lt;BR /&gt;
ods output &amp;lt;object&amp;gt; = dataset;&lt;BR /&gt;
proc freq data=mydata;&lt;BR /&gt;
  table char3;&lt;BR /&gt;
run;&lt;BR /&gt;
ods trace off;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
The documentation can show you the right syntax for the PROC FREQ method and the ODS TRACE and the ODS documentation can show you the correct syntax for the ODS method. The ODS TRACE will give you the name of the correct output object. As far as I know, "TABLE=TEST3" should fail because "TABLE" is not the correct output object name created by PROC FREQ.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 27 Jan 2009 14:06:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/column-percentage/m-p/71415#M20625</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-01-27T14:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: column percentage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/column-percentage/m-p/71416#M20626</link>
      <description>Brilliant Peter thanks.</description>
      <pubDate>Tue, 27 Jan 2009 14:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/column-percentage/m-p/71416#M20626</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-27T14:18:15Z</dc:date>
    </item>
  </channel>
</rss>

