<?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: Using ods to copy proc freq result tables to Excel in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-ods-to-copy-proc-freq-result-tables-to-Excel/m-p/958281#M374021</link>
    <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;suggests, use ODS Excel&amp;nbsp;&lt;STRONG&gt;always&lt;/STRONG&gt; and not ODS tagsets.ExcelXP. ODS Excel will create a native XLSX file that Excel will happily open. The old tagsets method creates an XML-based monster file that Excel no longer tolerates.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Feb 2025 21:53:58 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2025-02-04T21:53:58Z</dc:date>
    <item>
      <title>Using ods to copy proc freq result tables to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ods-to-copy-proc-freq-result-tables-to-Excel/m-p/958279#M374019</link>
      <description>&lt;P&gt;I have 10 FY of dental procedure data to send to a university researcher.&lt;/P&gt;
&lt;P&gt;There are well over a million records for each year.&amp;nbsp; I am using the proc freq&amp;nbsp; procedure to produce a table of procedure counts by age groups.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data ANALYZE5.Dental_CAPSTONE_FY2015_1_AgeGrp;
   length Age_group $14.; 
   Set ANALYZE5.Dental_CAPSTONE_Summary_FY2015;
If   18 &amp;lt;= Recipient_Age &amp;lt;= 25 then Age_group = '18-25';
Else If 26 &amp;lt;= Recipient_Age &amp;lt;= 35 then Age_group = '26-35';
Else If 36 &amp;lt;= Recipient_Age &amp;lt;= 45 then Age_group = '36-45';
Else If 46 &amp;lt;= Recipient_Age &amp;lt;= 55 then Age_group = '46-55';
Else If 56 &amp;lt;= Recipient_Age &amp;lt;= 65 then Age_group = '56-65';
Else If 66 &amp;lt;= Recipient_Age &amp;lt;= 752 then Age_group = '66-75';
Else If 76 &amp;lt;= Recipient_Age &amp;lt;= 85 then Age_group = '76-85';
Else If 85 &amp;lt;= Recipient_Age then Age_group = '85 and ';
run;


ods tagsets.excelxp 
file="H:\Univ_Alaska_Anchorage_data_DSSURS\FreqTable.xlsx" style=Printer options (Orientation = 'landscape');


proc freq data = ANALYZE5.Dental_CAPSTONE_FY2015_1_AgeGrp;
tables Procedure_Code___Desc * Age_group / nopercent norow nocol;

/*ods output FreqTable = Freq_Results_FY2015_1;*/
run;

ods tagsets.excelxp close;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When I run the code from the ods tagsets.excelxp line, the following error is produced&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;WARNING: Output 'FreqTable' was not created. Make sure that the output object name, label, or path is spelled correctly. Also, verify that the appropriate procedure options are used to produce the requested output object. For example, verify that the NOPRINT option is not used.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And in the folder where the output is to be sent has the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Excel cannot open the file 'FreqTable.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I appreciate all the help that comes from this group.&amp;nbsp; Thank you in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;wlierman&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 21:43:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ods-to-copy-proc-freq-result-tables-to-Excel/m-p/958279#M374019</guid>
      <dc:creator>wlierman</dc:creator>
      <dc:date>2025-02-04T21:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using ods to copy proc freq result tables to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ods-to-copy-proc-freq-result-tables-to-Excel/m-p/958280#M374020</link>
      <description>&lt;P&gt;&amp;nbsp;How about this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file="test.xlsx";
proc freq data=sashelp.class;
tables age;
run;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Feb 2025 21:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ods-to-copy-proc-freq-result-tables-to-Excel/m-p/958280#M374020</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-02-04T21:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using ods to copy proc freq result tables to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ods-to-copy-proc-freq-result-tables-to-Excel/m-p/958281#M374021</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;suggests, use ODS Excel&amp;nbsp;&lt;STRONG&gt;always&lt;/STRONG&gt; and not ODS tagsets.ExcelXP. ODS Excel will create a native XLSX file that Excel will happily open. The old tagsets method creates an XML-based monster file that Excel no longer tolerates.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 21:53:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ods-to-copy-proc-freq-result-tables-to-Excel/m-p/958281#M374021</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2025-02-04T21:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using ods to copy proc freq result tables to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ods-to-copy-proc-freq-result-tables-to-Excel/m-p/958284#M374022</link>
      <description>&lt;P&gt;If you want to continue using EXCELXP (which is still a good choice if you have an old SAS 9.4 maintenance level) then write to an XML file. This works with current versions of Excel in my experience:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods tagsets.excelxp 
file="H:\Univ_Alaska_Anchorage_data_DSSURS\FreqTable.xml" style=Printer options (Orientation = 'landscape');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;ODS EXCEL only became reliable from around 9.4M4 and higher.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 22:22:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ods-to-copy-proc-freq-result-tables-to-Excel/m-p/958284#M374022</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2025-02-04T22:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using ods to copy proc freq result tables to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ods-to-copy-proc-freq-result-tables-to-Excel/m-p/958294#M374030</link>
      <description>I have followed your suggestion and it provides a solution to my proble.&lt;BR /&gt;Thank you.&lt;BR /&gt;wlierman&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Feb 2025 00:11:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ods-to-copy-proc-freq-result-tables-to-Excel/m-p/958294#M374030</guid>
      <dc:creator>wlierman</dc:creator>
      <dc:date>2025-02-05T00:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using ods to copy proc freq result tables to Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-ods-to-copy-proc-freq-result-tables-to-Excel/m-p/958317#M374037</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/65907"&gt;@wlierman&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have 10 FY of dental procedure data to send to a university researcher.&lt;/P&gt;
&lt;P&gt;There are well over a million records for each year.&amp;nbsp; I am using the proc freq&amp;nbsp; procedure to produce a table of procedure counts by age groups.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data ANALYZE5.Dental_CAPSTONE_FY2015_1_AgeGrp;
   length Age_group $14.; 
   Set ANALYZE5.Dental_CAPSTONE_Summary_FY2015;
If   18 &amp;lt;= Recipient_Age &amp;lt;= 25 then Age_group = '18-25';
Else If 26 &amp;lt;= Recipient_Age &amp;lt;= 35 then Age_group = '26-35';
Else If 36 &amp;lt;= Recipient_Age &amp;lt;= 45 then Age_group = '36-45';
Else If 46 &amp;lt;= Recipient_Age &amp;lt;= 55 then Age_group = '46-55';
Else If 56 &amp;lt;= Recipient_Age &amp;lt;= 65 then Age_group = '56-65';
Else If 66 &amp;lt;= Recipient_Age &amp;lt;= 752 then Age_group = '66-75';
Else If 76 &amp;lt;= Recipient_Age &amp;lt;= 85 then Age_group = '76-85';
Else If 85 &amp;lt;= Recipient_Age then Age_group = '85 and ';
run;


ods tagsets.excelxp 
file="H:\Univ_Alaska_Anchorage_data_DSSURS\FreqTable.xlsx" style=Printer options (Orientation = 'landscape');


proc freq data = ANALYZE5.Dental_CAPSTONE_FY2015_1_AgeGrp;
tables Procedure_Code___Desc * Age_group / nopercent norow nocol;

/*ods output FreqTable = Freq_Results_FY2015_1;*/
run;

ods tagsets.excelxp close;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When I run the code from the ods tagsets.excelxp line, the following error is produced&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT color="#800080"&gt;&lt;STRONG&gt;WARNING: Output 'FreqTable' was not created. Make sure that the output object name, label, or path is spelled correctly.&lt;/STRONG&gt;&lt;/FONT&gt; Also, verify that the appropriate procedure options are used to produce the requested output object. For example, verify that the NOPRINT option is not used.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And in the folder where the output is to be sent has the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Excel cannot open the file 'FreqTable.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I appreciate all the help that comes from this group.&amp;nbsp; Thank you in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;wlierman&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The part I color highlighted is telling you that the "object" Freqtable is the problem. I am assuming the warning is from a run where the ODS OUTPUT statement was not commented.&lt;/P&gt;
&lt;P&gt;With Proc freq and ODS output you have two possible "frequency" table names: ONEWAYFREQS and CROSSTABFREQS. You can check the name of tables created in the online help Details tab under&amp;nbsp; ODS Table Names. Note there is no "FREQTABLE" anywhere.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If in question using ODS TRACE to get the names of the created output objects to use in a correct ODS OUTPUT option. Hint: with large data sets use the dataset option OBS=10 to generate the results quickly.&lt;/P&gt;
&lt;P&gt;Example that you can run using the SAS supplied SASHELP.CLASS data set:&lt;/P&gt;
&lt;PRE&gt;ods trace on;

proc freq data=sashelp.class;
tables sex*age /nopercent norow nocol;
run;

ods trace off;&lt;/PRE&gt;
&lt;P&gt;The Trace on and off start and end instructions to send trace output to the LOG. The result from the above, which mimics your options for Proc Freq shows this as the TRACE output:&lt;/P&gt;
&lt;PRE&gt;Output Added:
-------------
Name:       CrossTabFreqs
Label:      Cross-Tabular Freq Table
Template:   Base.Freq.CrossTabFreqs
Path:       Freq.Table1.CrossTabFreqs
-------------
&lt;/PRE&gt;
&lt;P&gt;Which means the only "table" is the Crosstabfreqs.&lt;/P&gt;
&lt;P&gt;To create the output data set using that approach would look like:&lt;/P&gt;
&lt;PRE&gt;proc freq data=sashelp.class;
   tables sex*age /nopercent norow nocol;
   ods output crosstabfreqs= Freq_result;
run;&lt;/PRE&gt;
&lt;P&gt;However that data set might not be as "nice" as you would like for output but that is the approach and syntax used correctly. &lt;/P&gt;
&lt;P&gt;The Trace information can bet a bit complex to match to desired data sets with the number of options that Proc Freq has coupled with the possibility of multiple TABLES statements in a single Procedure call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 06:02:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-ods-to-copy-proc-freq-result-tables-to-Excel/m-p/958317#M374037</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-02-05T06:02:41Z</dc:date>
    </item>
  </channel>
</rss>

