<?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: ODS EXCEL Sheet_interval with macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812948#M320769</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;What happened is that it created an excel file but for each macro (each pol and each category) but it seems like it was always the same category for each pol&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I don't understand this sentence. The code you presented can only create one Excel file. Can you please explain further.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 12 May 2022 13:14:03 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-05-12T13:14:03Z</dc:date>
    <item>
      <title>ODS EXCEL Sheet_interval with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812927#M320757</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am repeating a proc report with a macro in which parameters are different.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file = "...xlsx" 
 &amp;nbsp;&amp;nbsp;&amp;nbsp;options&amp;nbsp;(sheet_name&amp;nbsp;=&amp;nbsp;&amp;amp;pol.)&amp;nbsp;;&amp;nbsp;

%macro&amp;nbsp;report&amp;nbsp;(pol,category)&amp;nbsp;;&amp;nbsp;

proc&amp;nbsp;report&amp;nbsp;data&amp;nbsp;=&amp;nbsp;a_&amp;amp;pol._&amp;amp;category.&amp;nbsp;;

columns&amp;nbsp;..&amp;nbsp;;&amp;nbsp;
define&amp;nbsp;...&amp;nbsp;;&amp;nbsp;
run&amp;nbsp;;&amp;nbsp;
%mend&amp;nbsp;;&amp;nbsp;
%report(pol=A1,category=X)&amp;nbsp;;
%report(pol=A1,category=Y);
%report(pol=A1,category=Z);
/*&amp;nbsp;I&amp;nbsp;WANT&amp;nbsp;THESE&amp;nbsp;3&amp;nbsp;REPORTS&amp;nbsp;ABOVE&amp;nbsp;IN&amp;nbsp;THE&amp;nbsp;SAME&amp;nbsp;EXCEL&amp;nbsp;SHEET*/

/*NOW&amp;nbsp;I&amp;nbsp;WANT&amp;nbsp;THESE&amp;nbsp;3&amp;nbsp;OTHERS&amp;nbsp;IN&amp;nbsp;AN&amp;nbsp;OTHER&amp;nbsp;SHEET&amp;nbsp;&amp;nbsp;SO&amp;nbsp;I&amp;nbsp;TRIED&amp;nbsp;THIS CODE BELOW&amp;nbsp;BUT&amp;nbsp;IT&amp;nbsp;DIDN'T&amp;nbsp;WORK&amp;nbsp;:&amp;nbsp;*/

ods excel options(sheet_interval="now") ; 
%report(pol=A2,category=X)&amp;nbsp;;
%report(pol=A2,category=Y);
%report(pol=A2,category=Z);&lt;BR /&gt;ods&amp;nbsp;excel&amp;nbsp;close&amp;nbsp;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So i want one sheet for each POL i.e 3 tables x 2 sheets.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 12:22:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812927#M320757</guid>
      <dc:creator>elsfy</dc:creator>
      <dc:date>2022-05-12T12:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL Sheet_interval with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812934#M320763</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*NOW I WANT THESE 3 OTHERS IN AN OTHER SHEET  SO I TRIED THIS CODE BELOW BUT IT DIDN'T WORK : */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please explain what did happen. Also, was there an error in the log? If so, what?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, what version of SAS are you running? Run this command and let us know what the response is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put &amp;amp;sysvlong4;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 May 2022 12:37:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812934#M320763</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-12T12:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL Sheet_interval with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812940#M320766</link>
      <description>&lt;P&gt;It's v9.4 of SAS EG.&lt;BR /&gt;&lt;BR /&gt;What happened is that it created an excel file but for each macro (each pol and each category) but it seems like it was always the same category for each pol&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 12:55:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812940#M320766</guid>
      <dc:creator>elsfy</dc:creator>
      <dc:date>2022-05-12T12:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL Sheet_interval with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812943#M320767</link>
      <description>&lt;P&gt;Repeating: Run this command and let us know what the response is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put &amp;amp;sysvlong4;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 13:13:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812943#M320767</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-12T13:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL Sheet_interval with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812944#M320768</link>
      <description>9.04.01M7P08062020</description>
      <pubDate>Thu, 12 May 2022 13:03:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812944#M320768</guid>
      <dc:creator>elsfy</dc:creator>
      <dc:date>2022-05-12T13:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL Sheet_interval with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812948#M320769</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;What happened is that it created an excel file but for each macro (each pol and each category) but it seems like it was always the same category for each pol&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I don't understand this sentence. The code you presented can only create one Excel file. Can you please explain further.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 13:14:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812948#M320769</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-12T13:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL Sheet_interval with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812952#M320771</link>
      <description>&lt;P&gt;Sorry i forgot some words in my sentence. An excel file was created with multiple sheets. Each sheet corresponding to a pol and a category.&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 13:28:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812952#M320771</guid>
      <dc:creator>elsfy</dc:creator>
      <dc:date>2022-05-12T13:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL Sheet_interval with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812957#M320776</link>
      <description>&lt;P&gt;Provide the full definition of your proc report. What you want may be possible without any macro programming at all. Especially if you are doing the same combination of categories for each level of POL. Sheet_Interval='Bygroup' and using BY POL; in the report might be all you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example data, or program using an available SAS data set supplied in the SASHELP library, will help a lot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 13:29:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/812957#M320776</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-05-12T13:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL Sheet_interval with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/813001#M320792</link>
      <description>&lt;P&gt;It seems to me you just want to change the sheet interval and sheet name options at the appropriate times.&lt;/P&gt;
&lt;P&gt;Fix the ordering of your code to make it easier to understand.&amp;nbsp;Don't mix the macro definitions into the middle of the executable code.&amp;nbsp;Define the macro(s) first and then starting writing the code that will actually be run.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What names should the sheets have?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on this description&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;H4 class="xisDoc-argument"&gt;NOW&lt;/H4&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;BLOCKQUOTE&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;creates a new worksheet. When used, the next output object starts on a new sheet. After SHEET_INTERVAL='NOW' is executed, the SHEET_INTERVAL option reverts to the previous setting.&lt;/P&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;&amp;nbsp;&lt;/P&gt;
&lt;SECTION class="xisDoc-tableWrap"&gt;&lt;/SECTION&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;So t&lt;/SPAN&gt;&lt;SPAN&gt;his should work.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file = "...xlsx" ;
ods excel options (sheet_interval="none") ; 

ods excel options (sheet_name = "A1_sheet" ) ; 
ods excel options (sheet_interval="now") ; 
%report(pol=A1,category=X) ;
%report(pol=A1,category=Y);
%report(pol=A1,category=Z);

ods excel options (sheet_name = "A2_sheet" ) ; 
ods excel options (sheet_interval="now") ; 
%report(pol=A2,category=X) ;
%report(pol=A2,category=Y);
%report(pol=A2,category=Z);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If it doesn't try sprinkling in more&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel options(sheet_interval="none") ; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 15:12:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/813001#M320792</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-12T15:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL Sheet_interval with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/813002#M320793</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I get it but for my purpose i need to do a macro because for the 3rd POL value (i know ive only shown 2 POL values but i have more), i don't want to display a variable and if i don't do a macro, then it's going to be displayed (even if its values would be set to 0) for this POL. This is a variable that i want to display for all POL values except one. I hope it's not too confusing&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file = "...xlsx" 
    options (sheet_name = &amp;amp;pol.) ; 
%let noprint = noprint;
%macro report (pol,category,noprint) ; 

proc report data = a_&amp;amp;pol._&amp;amp;category. ;

columns .. ; 
define ... ; 
define var_x / &amp;amp;noprint. ; 
run ; 
%mend ; 
%report(pol=A1,category=X) ;
%report(pol=A1,category=Y);
%report(pol=A1,category=Z);
ods excel options(sheet_interval="now") ; 
%report(pol=A2,category=X) ;
%report(pol=A2,category=Y);
%report(pol=A2,category=Z);
ods excel options(sheet_interval="now") ; 
%report(pol=A3,category=X,noprint=&amp;amp;noprint.) ;
%report(pol=A4,category=Y,noprint=&amp;amp;noprint.);
%report(pol=A5,category=Z,noprint=&amp;amp;noprint.);
ods excel close ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 May 2022 15:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/813002#M320793</guid>
      <dc:creator>elsfy</dc:creator>
      <dc:date>2022-05-12T15:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL Sheet_interval with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/813005#M320794</link>
      <description>"It seems to me you just want to change the sheet interval and sheet name options at the appropriate times." &lt;BR /&gt;Yes it's exactly what i want to do. In fact, it might be an ordering problem in my case. Should i put the ODS EXCEL FILE before the %macro ?</description>
      <pubDate>Thu, 12 May 2022 15:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/813005#M320794</guid>
      <dc:creator>elsfy</dc:creator>
      <dc:date>2022-05-12T15:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL Sheet_interval with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/813007#M320795</link>
      <description>&lt;P&gt;NO.&amp;nbsp; It will just confuse YOU.&amp;nbsp; (SAS doesn't get confused since it is just software.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The %MACRO ... %MEND block just defines the macro.&amp;nbsp; So during those lines no actual SAS code is running.&amp;nbsp; It is when you call the macro that it can emit SAS code that can run.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So open the ODS destination before you run the first step that will produce output.&lt;/P&gt;
&lt;P&gt;And close it after the last output you want to include in that file.&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 15:49:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/813007#M320795</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-12T15:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL Sheet_interval with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/813008#M320796</link>
      <description>&lt;P&gt;Thank you very much. Adapting the code like this worked :&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro report; 
proc report ; 
%mend ; 

ods excel file="" 
options(sheet_interval="none") ; 

ods excel options(sheet_name="A1") ; 
%report(..);
%report(..);
%report(..);

ods excel options(sheet_name="A2") ; 
ods excel options(sheet_interval="now") ; 
%report(..);
%report(..);
%report(..);

ods excel options(sheet_name="A3") ; 
ods excel options(sheet_interval="now") ; 
%report(..);
%report(..);
%report(..);
ods excel close ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 16:08:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/813008#M320796</guid>
      <dc:creator>elsfy</dc:creator>
      <dc:date>2022-05-12T16:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: ODS EXCEL Sheet_interval with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/813015#M320801</link>
      <description>&lt;P&gt;Right.&amp;nbsp; If you set the NOW option before anything has been written if kind of messes it up.&lt;/P&gt;
&lt;P&gt;So you only want that before the 2nd, 3rd, etc sheets and not before the 1st sheet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 16:23:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-EXCEL-Sheet-interval-with-macro/m-p/813015#M320801</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-12T16:23:12Z</dc:date>
    </item>
  </channel>
</rss>

