<?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: Tagsets.excelxp within a macro in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Tagsets-excelxp-within-a-macro/m-p/218359#M53703</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;I find the macro quite hard to read.&amp;nbsp; I can see you want 2 Excel files with three tabs, thats easy enough:&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;data _null_;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set source;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by prot;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first.prot then call execute('ods tagsets.excelxp file="abc_'||strip(prot)||'.xml" options=(orientation="landscape");');&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('ods tagsets.excelxp options=(sheet_name='||strip(table_name)||');&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc print data=...;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;');&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if last.prot then call execute('ods tagsets.excelxp close;');&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;run;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;This will create two files each with three sheets.&amp;nbsp; Try to keep your code as simple and in blocks.&amp;nbsp; I.e. do one thing to get an output.&amp;nbsp; Then with that output move onto the next step.&amp;nbsp; Once it works once, then re-assess it to see if it can be put into a macro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 May 2015 14:28:26 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-05-22T14:28:26Z</dc:date>
    <item>
      <title>Tagsets.excelxp within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Tagsets-excelxp-within-a-macro/m-p/218358#M53702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Morning,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a macro that reads in data from multiple directories, manipulates the data so that only certain fields/records are kept, and then saves the output in the work directory. I am using call execute to pass values from a source table to each of my macro variables in the macro (example source data below). From the output, I want to use tagsets.excelxp to create one Excel workbook for each value of &amp;amp;prot, and then within each &amp;amp;prot workbook have multiple sheets for each value of &amp;amp;table. So, from the example data, I would want one workbook for Prot=AA1 with 3 worksheets (111, 222, 333) and one workbook for Prot=AA2 with 3 worksheets (111, 222, 333).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried to include my tagsets step at the bottom of the macro as indicated in bold below. However, I believe because I have multiple iterations of &amp;amp;prot within my source table (one for each unique value of &amp;amp;table), that the end result workbook is only keeping the worksheet with data from last unique value of &amp;amp;prot._&amp;amp;table (e.g. Workbook for prot=AA1, but only one worksheet for data for 333). What is best approach here for what I wish to accomplish?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro freetext (projid,prot,table,fieldlist);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; %if &amp;amp;projid=XXX %then %do; &lt;/P&gt;&lt;P&gt;libname &amp;amp;prot "path\&amp;amp;prot";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data &amp;amp;prot._&amp;amp;table;&lt;/P&gt;&lt;P&gt;set &amp;amp;prot..&amp;amp;table;&lt;/P&gt;&lt;P&gt;by prot;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array fieldname (*) $ &amp;amp;fieldlist:; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(fieldname);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if fieldname&lt;I&gt; ne '' then freetext=1;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; keep site prot patid &amp;amp;fieldlist; if freetext=1; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ods _all_ close;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ods tagsets.excelxp path="path\&amp;amp;prot\" file="freetext_&amp;amp;prot..xls";&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;options (orientation='Landscape'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; style=statistical;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ods tagsets.ExcelXP&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc print data=&amp;amp;prot._&amp;amp;table noobs; options nocenter; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ods tagsets.excelxp options(sheet_name="&amp;amp;table"); run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ods tagsets.excelxp close;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend freetext;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set source;&lt;/P&gt;&lt;P&gt;call&lt;/P&gt;&lt;P&gt;execute('%freetext('||projid||','||prot||','||table_name||','||fieldlist||')');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;PROJID&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;PROT&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;TABLE_NAME&lt;BR /&gt;&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;AAA&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;AA1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;111&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;AAA&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;AA1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;222&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;AAA&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;AA1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;333&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;AAA&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;AA2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;111&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;AAA&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;AA2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;222&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;AAA&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;AA2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;333&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 May 2015 14:04:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Tagsets-excelxp-within-a-macro/m-p/218358#M53702</guid>
      <dc:creator>lbarwick</dc:creator>
      <dc:date>2015-05-22T14:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: Tagsets.excelxp within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Tagsets-excelxp-within-a-macro/m-p/218359#M53703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;I find the macro quite hard to read.&amp;nbsp; I can see you want 2 Excel files with three tabs, thats easy enough:&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;data _null_;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set source;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by prot;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first.prot then call execute('ods tagsets.excelxp file="abc_'||strip(prot)||'.xml" options=(orientation="landscape");');&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('ods tagsets.excelxp options=(sheet_name='||strip(table_name)||');&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc print data=...;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;');&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if last.prot then call execute('ods tagsets.excelxp close;');&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;run;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;This will create two files each with three sheets.&amp;nbsp; Try to keep your code as simple and in blocks.&amp;nbsp; I.e. do one thing to get an output.&amp;nbsp; Then with that output move onto the next step.&amp;nbsp; Once it works once, then re-assess it to see if it can be put into a macro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 May 2015 14:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Tagsets-excelxp-within-a-macro/m-p/218359#M53703</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-05-22T14:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Tagsets.excelxp within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Tagsets-excelxp-within-a-macro/m-p/218360#M53704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are invoking ODS TAGSETS.EXCELXP several times, and I'm not sure why you are doing that. You even have one with no semi-colon on the end and no options for the ODS TAGSETS.EXCELXP statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you want only one such ODS TAGSETS.EXCELXP statement in the macro, and one ODS TAGSETS.EXCELXP CLOSE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Furthermore, the first time you run the macro, you specifiy both the file and sheet_name in one ODS TAGSETS.EXCELP statement. The next time your execute the macro, you'd want to make sure there is no file= but there is a sheet_name=. Finally, when all is done, all sheets have been written, you then issue the ODS TAGSETS.EXCELXP CLOSE; command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: Looks like &lt;A __default_attr="814511" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; has offered the same solution, with some example code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 May 2015 14:30:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Tagsets-excelxp-within-a-macro/m-p/218360#M53704</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2015-05-22T14:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: Tagsets.excelxp within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Tagsets-excelxp-within-a-macro/m-p/218361#M53705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for feedback,and sorry about typos in macro - working remotely today and hard to toggle b/tw VPN session and this site.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see what your example is trying to do, and I'm assuming this gets nested within my existing macro? My code isbelow but get an error. I had to modify the proc print data step so that it would read the data correctly from work directory, otherwise everything else is same as suggested.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;8&amp;nbsp;&amp;nbsp; !+last.prot then call execute('ods tagsets.excelxp close;');&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;ERROR: Undeclared array referenced: execute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 79-322: Expecting a ;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: +, =.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=source; by prot; run;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set source;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by prot;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first.prot then call execute('ods tagsets.excelxp file=(abc_'||strip(prot)||'.xml)');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('ods tagsets.excelxp options=(sheet_name='||strip(table_name)||');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc print data=('||strip(prot)||'_'||strip(table_name)||'); run;')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if last.prot then call execute('ods tagsets.excelxp close;');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 May 2015 16:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Tagsets-excelxp-within-a-macro/m-p/218361#M53705</guid>
      <dc:creator>lbarwick</dc:creator>
      <dc:date>2015-05-22T16:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Tagsets.excelxp within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Tagsets-excelxp-within-a-macro/m-p/218362#M53706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alright, sorry for additional reply but I got the output I wanted by putting the following code outside my macro. Two issues remain:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;when I include '||strip(table_name)||' after sheet_name=, the log says it is expecting a quoted string. But - I can see from the log that the program is resolving sheet_name to the value of table_name. If I instead enclose ||strip(table_name)|| in double quotes, the program runs without error, but now all the sheet names in the output are the string literal "||strip(table_name)||". Any thoughts?&lt;/LI&gt;&lt;LI&gt;When the program runs without error, I get a warning:&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;WARNING: Data too long for column "XXX"; truncated to 91 characters to fit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I override the default length?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set source;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by prot;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first.prot then call execute('ods tagsets.excelxp path="path\'||strip(prot)||'"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; file="abc_'||strip(prot)||'.xml";');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('ods tagsets.excelxp options(sheet_name="test");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc print data='||strip(prot)||'_'||strip(table_name)||'; run;');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if last.prot then call execute('ods tagsets.excelxp close;');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 May 2015 18:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Tagsets-excelxp-within-a-macro/m-p/218362#M53706</guid>
      <dc:creator>lbarwick</dc:creator>
      <dc:date>2015-05-22T18:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Tagsets.excelxp within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Tagsets-excelxp-within-a-macro/m-p/218363#M53707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well point 1 is simple and my fault, the code was missing a bit:&lt;/P&gt;&lt;P&gt;call execute('ods tagsets.excelxp options=(sheet_name="'||strip(table_name)||'");&lt;/P&gt;&lt;P&gt;You will note after the sheet_name= there is a double quote ", then a single quote.&amp;nbsp; The call execute accepts a string, hence it needs to be quoted - in my case I use single quotes for the complete string.&amp;nbsp; Within that string we are generating, the sheet_name also requires a string, so that needs to be quoted as well, so I use double quotes.&lt;/P&gt;&lt;P&gt;What this should then say is:&lt;/P&gt;&lt;P&gt;add the text ods tagsets.excelxp options=(sheet_name="&lt;/P&gt;&lt;P&gt;to the program stream.&lt;/P&gt;&lt;P&gt;Then the text from the variable table name&lt;/P&gt;&lt;P&gt;Then the text ");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That might resolve your second issue also however if table_name is longer than 91 you will have problems as Excel has limits on length.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 May 2015 10:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Tagsets-excelxp-within-a-macro/m-p/218363#M53707</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-05-23T10:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Tagsets.excelxp within a macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Tagsets-excelxp-within-a-macro/m-p/218364#M53708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, this worked! And I solved the truncation issue by adding 'ods listing close' before the data step that prints the reports.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 May 2015 12:49:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Tagsets-excelxp-within-a-macro/m-p/218364#M53708</guid>
      <dc:creator>lbarwick</dc:creator>
      <dc:date>2015-05-26T12:49:02Z</dc:date>
    </item>
  </channel>
</rss>

