<?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 FREQ with many variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-with-many-variables/m-p/460042#M284611</link>
    <description>&lt;P&gt;Sure, but that is not the most efficient way. What if I have 10000 variables? Of course, you can write 10000 lines. What I am asking is something more efficient than that.&lt;/P&gt;</description>
    <pubDate>Fri, 04 May 2018 14:03:08 GMT</pubDate>
    <dc:creator>John927</dc:creator>
    <dc:date>2018-05-04T14:03:08Z</dc:date>
    <item>
      <title>PROC FREQ with many variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-with-many-variables/m-p/460031#M284609</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suppose I have p=3 categorical variables A, B, C and I would like frequency tables for each pair: A*B, A*C, B*C. Of course, I can run 3 PROC FREQ. But if I have p=10, there will be many more PROC FREQ. On the other hand, the following code can generate additional tables for A*A, B*B and C*C, which are not needed.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC FREQ&amp;nbsp;&lt;/P&gt;&lt;P&gt;TABLES (A B C)*(A B C)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Question: how to do this efficiently and generate tables only needed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 13:35:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-with-many-variables/m-p/460031#M284609</guid>
      <dc:creator>John927</dc:creator>
      <dc:date>2018-05-04T13:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ with many variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-with-many-variables/m-p/460038#M284610</link>
      <description>&lt;P&gt;Couldn't you just use something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=sashelp.cars;
  tables make * (type origin drivetrain);
  tables type * (origin drivetrain);
  tables origin*drivetrain;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 13:57:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-with-many-variables/m-p/460038#M284610</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-05-04T13:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ with many variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-with-many-variables/m-p/460042#M284611</link>
      <description>&lt;P&gt;Sure, but that is not the most efficient way. What if I have 10000 variables? Of course, you can write 10000 lines. What I am asking is something more efficient than that.&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 14:03:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-with-many-variables/m-p/460042#M284611</guid>
      <dc:creator>John927</dc:creator>
      <dc:date>2018-05-04T14:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ with many variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-with-many-variables/m-p/460044#M284612</link>
      <description>&lt;P&gt;Why would you have 10k variables.&amp;nbsp; Sorry, this is something which comes up 3 or 4 times a day.&amp;nbsp; Transposed data makes your coding life harder.&amp;nbsp; Keep your data in long form - this way you can have any number of items, and number of variables is really small and easy to manage.&amp;nbsp; SAS is not Excel!&amp;nbsp; If you provide some test data in the form of a datastep then we can come up with some code.&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 14:08:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-with-many-variables/m-p/460044#M284612</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-04T14:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ with many variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-with-many-variables/m-p/460047#M284613</link>
      <description>&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;freq&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;sashelp&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;cars&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;tables&lt;/SPAN&gt; make &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;type origin drivetrain&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;tables&lt;/SPAN&gt; type &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;origin drivetrain&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;tables&lt;/SPAN&gt; origin&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;drivetrain&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In the above example posted by art297, there are 3 tables statement. Alternative, how to do this in just one table statement and achieve the same exactly results?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 14:22:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-with-many-variables/m-p/460047#M284613</guid>
      <dc:creator>John927</dc:creator>
      <dc:date>2018-05-04T14:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ with many variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-with-many-variables/m-p/460056#M284614</link>
      <description>&lt;P&gt;Here is an alternative. It wouldn't work for 10,000 variables, but would work if the total number of characters needed for the tables statement was less than 64K:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data vars;
  input var1 $32.;
  cards;
make
type
origin
drivetrain
;

proc sql noprint;
    select catx(' ','tables',a.var1,'*',b.var2,';')
      into : tables separated by ' '
        from vars a, vars (rename=(var1=var2)) b
          where var1 ne var2 and
                var1 gt var2
  ;
quit;

proc freq data=sashelp.cars;
  &amp;amp;tables.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 14:35:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-with-many-variables/m-p/460056#M284614</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-05-04T14:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ with many variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-with-many-variables/m-p/460086#M284615</link>
      <description>&lt;P&gt;Thanks. It works very nicely.&lt;/P&gt;</description>
      <pubDate>Fri, 04 May 2018 15:24:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-with-many-variables/m-p/460086#M284615</guid>
      <dc:creator>John927</dc:creator>
      <dc:date>2018-05-04T15:24:00Z</dc:date>
    </item>
  </channel>
</rss>

