<?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: Export results from proc freq 2 by 2 table to excel in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500812#M72633</link>
    <description>Thank you for the information and I did not know about the code simplification. Thank you for that. I will try the code you provided.</description>
    <pubDate>Tue, 02 Oct 2018 15:26:26 GMT</pubDate>
    <dc:creator>PaulaC</dc:creator>
    <dc:date>2018-10-02T15:26:26Z</dc:date>
    <item>
      <title>Export results from proc freq 2 by 2 table to excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500611#M72621</link>
      <description>&lt;P&gt;I would like to export the results (each 2 by 2 table) from proc freq to excel.&amp;nbsp; &amp;nbsp;I have 29 variables in my proc freq tables statement.&amp;nbsp; Each variable will produce a 2 by 2 table with study type status.&amp;nbsp; For example: age*study.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I initially tried using the out statement option in the table statement and then was going to export to Excel. Unfortunately only the results for the last variable in my list got output.&amp;nbsp; I feel that this should be an easy fix, but have not been able to find an answer online.&lt;/P&gt;&lt;P&gt;My code is as follows:&lt;/P&gt;&lt;P&gt;proc freq data=data;&lt;BR /&gt;tables sex*study race*study countrygrp*study totcomorbid*study risk*study totmetsites*study metloc*study visceral*study&amp;nbsp;&lt;BR /&gt;nonvisceral*study breast*study skin*study bone*study liver*study lung*study lymphnode*study othersite*study priortrt*study&amp;nbsp;&lt;BR /&gt;priorrx*study&amp;nbsp;chemotherapy*study surgery*study radiotherapy*study regradio*study metradio*study hormonal*study bestresp*study&amp;nbsp;&lt;BR /&gt;suppcare*study whob*study&amp;nbsp;arm*study numpt*study/norow nopercent out=freq;&lt;BR /&gt;where exclude =. &amp;amp; visn = 1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help you could provide would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Paula&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 02:47:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500611#M72621</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2018-10-02T02:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: Export results from proc freq 2 by 2 table to excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500636#M72626</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/How-to-output-multiple-variables-from-proc-freq-into-a-dataset/td-p/70836&amp;nbsp;" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/How-to-output-multiple-variables-from-proc-freq-into-a-dataset/td-p/70836&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 07:05:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500636#M72626</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-10-02T07:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Export results from proc freq 2 by 2 table to excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500763#M72628</link>
      <description>Thank you for the response, but unfortunately the link did not work. Would you be able to send me the complete title so I can search for it?&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Oct 2018 14:27:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500763#M72628</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2018-10-02T14:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: Export results from proc freq 2 by 2 table to excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500785#M72629</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/107488"&gt;@PaulaC&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I would like to export the results (each 2 by 2 table) from proc freq to excel.&amp;nbsp; &amp;nbsp;I have 29 variables in my proc freq tables statement.&amp;nbsp; Each variable will produce a 2 by 2 table with study type status.&amp;nbsp; For example: age*study.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I initially tried using the out statement option in the table statement and then was going to export to Excel. Unfortunately only the results for the last variable in my list got output.&amp;nbsp; I feel that this should be an easy fix, but have not been able to find an answer online.&lt;/P&gt;
&lt;P&gt;My code is as follows:&lt;/P&gt;
&lt;P&gt;proc freq data=data;&lt;BR /&gt;tables sex*study race*study countrygrp*study totcomorbid*study risk*study totmetsites*study metloc*study visceral*study&amp;nbsp;&lt;BR /&gt;nonvisceral*study breast*study skin*study bone*study liver*study lung*study lymphnode*study othersite*study priortrt*study&amp;nbsp;&lt;BR /&gt;priorrx*study&amp;nbsp;chemotherapy*study surgery*study radiotherapy*study regradio*study metradio*study hormonal*study bestresp*study&amp;nbsp;&lt;BR /&gt;suppcare*study whob*study&amp;nbsp;arm*study numpt*study/norow nopercent out=freq;&lt;BR /&gt;where exclude =. &amp;amp; visn = 1;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help you could provide would be greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Paula&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;ods excel file="&amp;lt;path&amp;gt;\filename.xlsx";&lt;/P&gt;
&lt;P&gt;&amp;lt;proc freq code goes here&amp;gt;&lt;/P&gt;
&lt;P&gt;ods excel close;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;would be one way where &amp;lt;path&amp;gt; is the path to the desired output location such as c:\projectfolder or similar. There are options for ODS EXCEL to have some control over one tab per table or one tab for the procedure and such.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you familiar with the notation in Proc Freq that shows how to cross groups of variables?&lt;/P&gt;
&lt;P&gt;You can simplify the code for a tables statement by using parentheses and the * For example&lt;/P&gt;
&lt;PRE&gt;nonvisceral*study breast*study skin*study bone*study liver*study lung*study lymphnode*study othersite*study priortrt*study &lt;/PRE&gt;
&lt;P&gt;could instead be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(nonvisceral breast skin bone liver lung ymphnode othersite priortrt)* study&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Oct 2018 14:54:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500785#M72629</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-02T14:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Export results from proc freq 2 by 2 table to excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500791#M72630</link>
      <description>&lt;P&gt;Here's the link corrected.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/How-to-output-multiple-variables-from-proc-freq-into-a-dataset/td-p/70836" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/How-to-output-multiple-variables-from-proc-freq-into-a-dataset/td-p/70836&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And here's another option, it's not particularly efficient but I like this macro. Run this as a demo (assuming your input data set is really called data) and then check the output data set, which is in summary_demo in the work library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let source_path =https://gist.githubusercontent.com/statgeek/0ff46bbd76bcc101e40945816b232303/raw/712547f2e6feb20858322948c7a163237cb341e7/summary_table.sas;

filename reprex url "&amp;amp;source_path";
%include reprex;
filename reprex;


%let var_demo = sex race countrygrp;
%summary_table(dsetin = data, 
            dsetout = summary_demo, 
            varlist = &amp;amp;var_demo, 
            varcross = study, 
            rc = col, 
            missing=, 
            replace=Y, 
            nlevel_cutoff=25);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 15:01:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500791#M72630</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-02T15:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: Export results from proc freq 2 by 2 table to excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500810#M72631</link>
      <description>Thank you for the information. Would you be able to explain the steps in the macro for me? I am not 100% clear on how it is working.</description>
      <pubDate>Tue, 02 Oct 2018 15:25:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500810#M72631</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2018-10-02T15:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Export results from proc freq 2 by 2 table to excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500812#M72633</link>
      <description>Thank you for the information and I did not know about the code simplification. Thank you for that. I will try the code you provided.</description>
      <pubDate>Tue, 02 Oct 2018 15:26:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500812#M72633</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2018-10-02T15:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: Export results from proc freq 2 by 2 table to excel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500853#M72638</link>
      <description>&lt;P&gt;You can see the code, go to the linked path in source path. It's basically a PROC FREQ loop that appends all the results together in a somewhat nicely formatted table with the N (##%) values formatted.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 17:17:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Export-results-from-proc-freq-2-by-2-table-to-excel/m-p/500853#M72638</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-02T17:17:22Z</dc:date>
    </item>
  </channel>
</rss>

