<?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 Two way table using PROC TABULATE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Two-way-table-using-PROC-TABULATE/m-p/730812#M227619</link>
    <description>&lt;P&gt;I have the following data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format;&lt;BR /&gt;picture count (round)&lt;BR /&gt;0-4 = ' &amp;lt;5' (NOEDIT);&lt;BR /&gt;picture pcnt (round)&lt;BR /&gt;0 = ' - '&lt;BR /&gt;other = '009.9%';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA HAVE;&lt;BR /&gt;input year dz $8. area;&lt;BR /&gt;cards;&lt;BR /&gt;2000 stroke 08&lt;BR /&gt;2000 stroke 06&lt;BR /&gt;2000 stroke 06&lt;BR /&gt;2001 stroke 08&lt;BR /&gt;2001 stroke 06&lt;BR /&gt;2001 stroke 06&lt;BR /&gt;2002 stroke 08&lt;BR /&gt;2002 stroke 06&lt;BR /&gt;2002 stroke 06&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;I want a 2-D table and&amp;nbsp;want to present 'Frequency' and 'Row Pct' and retain the 'Total' row; I also want to mask values below 5 in 'Frequency' using format 'count.' and 'pcnt.'&lt;/P&gt;
&lt;P&gt;I have tried using PROC TABULATE which would be an easier option for me&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc tabulate data=have;&lt;BR /&gt;class area year;&lt;BR /&gt;classlev year / s=[just=left];&lt;BR /&gt;keylabel pctn='%';&lt;BR /&gt;tables year=' ' ((area=' ')*(n='Frequency'*f=count. rowpctn='Percent'*f=pcnt.) &lt;BR /&gt;(all='Total')*(n='Frequency'*f=count. rowpctn='Percent'*f=pcnt.))&lt;BR /&gt;/box=year;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However this code is giving me the following error&lt;/P&gt;
&lt;P&gt;ERROR: Too few dimensions specified in the following nesting : area * RowPctN * f.&lt;BR /&gt;ERROR: Too few dimensions specified in the following nesting : All * RowPctN * f.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am new to proc tabulate and cannot understand what this error is about.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When using proc freq I get the below output.&lt;/P&gt;
&lt;P&gt;proc freq data=HAVE;&lt;BR /&gt;tables year*area;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Priyamvada07_0-1617304213983.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56812iDE365DB6A9B25C9A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Priyamvada07_0-1617304213983.png" alt="Priyamvada07_0-1617304213983.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I use the below code to remove cumulative row I get the table in another way which is not desired.&lt;/P&gt;
&lt;P&gt;proc freq data=HAVE;&lt;BR /&gt;tables area / list nocum out=a;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a one way table I was able to create a output using 'out=a' and then use the formats 'count.' and 'pcnt.' in the PROC PRINT step. The code that I used for one way table is as below&lt;/P&gt;
&lt;P&gt;proc freq data=HAVE_rev;&lt;BR /&gt;tables area / list nocum out=a;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc print data=a;&lt;BR /&gt;format count count. percent pcnt. ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, this is not giving me the desired result for two way table!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any guidance on this preferably using PROC TABULATE (PROC FREQ will also do)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Apr 2021 19:10:27 GMT</pubDate>
    <dc:creator>Priyamvada07</dc:creator>
    <dc:date>2021-04-01T19:10:27Z</dc:date>
    <item>
      <title>Two way table using PROC TABULATE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-way-table-using-PROC-TABULATE/m-p/730812#M227619</link>
      <description>&lt;P&gt;I have the following data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format;&lt;BR /&gt;picture count (round)&lt;BR /&gt;0-4 = ' &amp;lt;5' (NOEDIT);&lt;BR /&gt;picture pcnt (round)&lt;BR /&gt;0 = ' - '&lt;BR /&gt;other = '009.9%';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA HAVE;&lt;BR /&gt;input year dz $8. area;&lt;BR /&gt;cards;&lt;BR /&gt;2000 stroke 08&lt;BR /&gt;2000 stroke 06&lt;BR /&gt;2000 stroke 06&lt;BR /&gt;2001 stroke 08&lt;BR /&gt;2001 stroke 06&lt;BR /&gt;2001 stroke 06&lt;BR /&gt;2002 stroke 08&lt;BR /&gt;2002 stroke 06&lt;BR /&gt;2002 stroke 06&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;I want a 2-D table and&amp;nbsp;want to present 'Frequency' and 'Row Pct' and retain the 'Total' row; I also want to mask values below 5 in 'Frequency' using format 'count.' and 'pcnt.'&lt;/P&gt;
&lt;P&gt;I have tried using PROC TABULATE which would be an easier option for me&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc tabulate data=have;&lt;BR /&gt;class area year;&lt;BR /&gt;classlev year / s=[just=left];&lt;BR /&gt;keylabel pctn='%';&lt;BR /&gt;tables year=' ' ((area=' ')*(n='Frequency'*f=count. rowpctn='Percent'*f=pcnt.) &lt;BR /&gt;(all='Total')*(n='Frequency'*f=count. rowpctn='Percent'*f=pcnt.))&lt;BR /&gt;/box=year;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However this code is giving me the following error&lt;/P&gt;
&lt;P&gt;ERROR: Too few dimensions specified in the following nesting : area * RowPctN * f.&lt;BR /&gt;ERROR: Too few dimensions specified in the following nesting : All * RowPctN * f.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am new to proc tabulate and cannot understand what this error is about.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When using proc freq I get the below output.&lt;/P&gt;
&lt;P&gt;proc freq data=HAVE;&lt;BR /&gt;tables year*area;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Priyamvada07_0-1617304213983.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56812iDE365DB6A9B25C9A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Priyamvada07_0-1617304213983.png" alt="Priyamvada07_0-1617304213983.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I use the below code to remove cumulative row I get the table in another way which is not desired.&lt;/P&gt;
&lt;P&gt;proc freq data=HAVE;&lt;BR /&gt;tables area / list nocum out=a;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a one way table I was able to create a output using 'out=a' and then use the formats 'count.' and 'pcnt.' in the PROC PRINT step. The code that I used for one way table is as below&lt;/P&gt;
&lt;P&gt;proc freq data=HAVE_rev;&lt;BR /&gt;tables area / list nocum out=a;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc print data=a;&lt;BR /&gt;format count count. percent pcnt. ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, this is not giving me the desired result for two way table!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any guidance on this preferably using PROC TABULATE (PROC FREQ will also do)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 19:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-way-table-using-PROC-TABULATE/m-p/730812#M227619</guid>
      <dc:creator>Priyamvada07</dc:creator>
      <dc:date>2021-04-01T19:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Two table using PROC TABULATE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-way-table-using-PROC-TABULATE/m-p/730815#M227620</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;When I use the below code to remove cumulative row I get the table in another way which is not desired.&lt;/P&gt;
&lt;P&gt;proc freq data=HAVE;&lt;BR /&gt;tables area / list nocum out=a;&lt;BR /&gt;run;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;NOCUM removes the cumulative, but LIST changes the layout of the table. If you don't want the layout changed, remove the LIST option. But your previous code as a nxn table and this is a one way table so it's not even the same problem. A nxn table does not have a cumulative column, it has the row/col percent which can also be controlled with options in PROC FREQ.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please show EXACTLY what you want as output. You have a couple of requirements but it's not clear, so far:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;N and PCTN for one way tables, not sure about nxn tables.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Masking for N&amp;gt;5 -&amp;gt; what about the percent values&lt;/LI&gt;
&lt;LI&gt;Which columns combined? FREQ puts them on the same cell, TABULATE does not.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;I suspect your code from the previous post is missing a comma.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FYI - I'm assuming you've reviewed the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=proc&amp;amp;docsetTarget=p09qs3m2djd7bgn1g464ln0pr48c.htm&amp;amp;locale=en" target="_self"&gt;documentation&lt;/A&gt; and are slowly building your procs step by step. So first start with a base table and then add in the features such as (ALL, PCTN and formats) as you go so you can test each option as you add it. If I tried to write a PROC TABULATE with that structure from scratch I'd get it wrong for sure and would also follow this process even though I've been programming for 15 years.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 19:11:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-way-table-using-PROC-TABULATE/m-p/730815#M227620</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-01T19:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: Two table using PROC TABULATE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-way-table-using-PROC-TABULATE/m-p/730824#M227624</link>
      <description>&lt;P&gt;Looks like in the PROC TABULATE code 'it was all about the comma'!!!! Thank you very much for pointing that out and all other info, very very helpful. I got my desired table &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Priyamvada07_0-1617305097736.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56815i54BDEA925D33F869/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Priyamvada07_0-1617305097736.png" alt="Priyamvada07_0-1617305097736.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Apr 2021 19:25:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-way-table-using-PROC-TABULATE/m-p/730824#M227624</guid>
      <dc:creator>Priyamvada07</dc:creator>
      <dc:date>2021-04-01T19:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Two table using PROC TABULATE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-way-table-using-PROC-TABULATE/m-p/730833#M227627</link>
      <description>FYI - if you display percents and your total is &amp;gt;5 and displayed you can work backwards to figure out the N's so that suppression may not be adequate.</description>
      <pubDate>Thu, 01 Apr 2021 19:52:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-way-table-using-PROC-TABULATE/m-p/730833#M227627</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-01T19:52:01Z</dc:date>
    </item>
  </channel>
</rss>

