<?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: Output/creating multiple excel documents - with preexisting excel template in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/291627#M16625</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Options noxwait noxsync;
%macro Tool(ID);

%sysexec copy "U:\SMRT\Med Review Tool Pilot\Oxy Review Tool\OxygenMRPilot0811_d2.xlsx" 
     "C:\testsas\OxygenMRPilot_&amp;amp;ID..xlsx" ; 
run;


%exportxl( data=TestOxy (Where=(sample_ID="&amp;amp;ID")) ,
   outfile= C:\testsas\OxygenMRPilot_&amp;amp;ID..xlsx,
   Sheet=SMRT,
   Type=M,
   Replace=N,
   useformats=Y);
run;
%MEND;

Data _null_;
Set idlist;

Str = catt('%tool(', id, ');');
Call execute ( Str);

Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 15 Aug 2016 02:40:07 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-08-15T02:40:07Z</dc:date>
    <item>
      <title>Output/creating multiple excel documents - with preexisting excel template</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/290005#M16589</link>
      <description>&lt;P&gt;Hi I'm SURE I can do this in SAS. This is SAS-9.4 and no, we don't have ACCESS to PC.&lt;BR /&gt;We have an excel-based tool we want to use to complete over 5,000 reviews. I need a way to populate ONE named tab and generate 5,000 copies of the tool - based on my sas data. Here's the code I'm using to generate 20 separate tabs within 1 excel document (as a test):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods listing close; 
ods tagsets.ExcelXP file="testfile.xml" path="C:\testsas\" style=Statistical; 

proc print data=testset noobs label; 
by sampleid; 
var contractorID sampid linenumber UnitsBilled AmtPaid ; 
run; 

ods tagsets.ExcelXP close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I need instead is to insert the data from the SAS dataset a named tab in a specific excel document, &lt;BR /&gt;and generate as many excel documents as there are sampleids (i.e. the BY var). &lt;BR /&gt;So, I have an existing Excel document Tool.xls with 5 tabs. I want to put the SAS data into the tab &lt;BR /&gt;named "Sample" save the excel document with the new name Tool_1.xls ... repeat for the 5,000 by-vars.&lt;BR /&gt; Help! I'm a huge booster of SAS, and I want to prove we can do it very slickly with SAS. Please don't deflate my faith in SAS!&lt;BR /&gt; thank you!&lt;/P&gt;</description>
      <pubDate>Sun, 07 Aug 2016 04:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/290005#M16589</guid>
      <dc:creator>Geetu</dc:creator>
      <dc:date>2016-08-07T04:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Output/creating multiple excel documents - with preexisting excel template</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/290009#M16590</link>
      <description>&lt;P&gt;Personally, I would switch to XLSX as a minimum.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would also purchase Access to PC because the cost savings versus extra time is a no brainer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an alternative option:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export" target="_blank"&gt;http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to get into the difficult arena, look into DDE, though you'll get the response it's not supported any longer. And that's true as well. However, it still works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This doesn't quite stand alone as a presentation, but it does have some sample code.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.sas.com/content/dam/SAS/en_ca/User%20Group%20Presentations/Edmonton-User-Group/FareezaKhurshed-CoordinateComplexReports-Spring2014.pdf" target="_blank"&gt;http://www.sas.com/content/dam/SAS/en_ca/User%20Group%20Presentations/Edmonton-User-Group/FareezaKhurshed-CoordinateComplexReports-Spring2014.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do need to be working on a desktop installation (vs server) for DDE to work and have X command enabled. This allows you to copy the template and save as a new copy X 5000 times. Then you export to the new copy and voila, you're done. Your process sounds relatively simple.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Good Luck.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Aug 2016 04:37:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/290009#M16590</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-07T04:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: Output/creating multiple excel documents - with preexisting excel template</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/290054#M16591</link>
      <description>&lt;P&gt;Thank you Reeza!&lt;/P&gt;&lt;P&gt;I appreciate the guidance. &amp;nbsp;I'll look into getting the company to spring for Access to PC, but as usual, the current problem needs solving yesterday! &amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll review the information you sent, work on the problem tonight, and report back.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Aug 2016 23:33:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/290054#M16591</guid>
      <dc:creator>Geetu</dc:creator>
      <dc:date>2016-08-07T23:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Output/creating multiple excel documents - with preexisting excel template</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/290163#M16594</link>
      <description>&lt;P&gt;Argh! &amp;nbsp;So close!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all the Exportxl Macro provided in the paper you linked works. Yay! &amp;nbsp;It rocks actually, and I can see using it a lot in future.&lt;/P&gt;&lt;P&gt;I ran my test dataset of 20 records - specifying the Excel document that has all the multiple tabs I need.&lt;/P&gt;&lt;P&gt;The 20 records were put into the specified tab in that Excel document ... slick as anything.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd still need to manipulate the data to export records based on the "BY" variable .. but I thought I could write a macro for that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the problem is that the Exportxl macro requires that the resulting Excel document is already created and named ... which means I still need to create 1000s of the initial Excel workbooks which then can have the data inserted by this macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Back to researching ...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 12:29:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/290163#M16594</guid>
      <dc:creator>Geetu</dc:creator>
      <dc:date>2016-08-08T12:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Output/creating multiple excel documents - with preexisting excel template</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/290171#M16595</link>
      <description>&lt;P&gt;The second link covers that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;X copy ...&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 12:52:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/290171#M16595</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-08T12:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: Output/creating multiple excel documents - with preexisting excel template</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/290184#M16596</link>
      <description>&lt;P&gt;Thanks Reeza ... I'm now digging into x copy and figuring it out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I promise to post my solution here when I'm done.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cheers!&lt;/P&gt;&lt;P&gt;geetu&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 13:25:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/290184#M16596</guid>
      <dc:creator>Geetu</dc:creator>
      <dc:date>2016-08-08T13:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Output/creating multiple excel documents - with preexisting excel template</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/291622#M16622</link>
      <description>&lt;P&gt;Thanks so much Reeza!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your assistance led me to the right solution for making a copy of the starting Excel document and using the Macro to modify one of the worksheets. &amp;nbsp;That worked great!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My challenge is to get it to work for 10,000 times ... I thought of using a Macro ... which would still mean I'd have to run 10,000 lines but I can't get a macro to work within the&amp;nbsp;%exportxl macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what I've done:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Tool(ID);

data tool1;
set testOxy ;
if sample_ID = "&amp;amp;id";
format From_Date To_Date Billed_Date mmddyy10.;
run;

options noxwait noxsync;
%sysexec copy "U:\SMRT\Med Review Tool Pilot\Oxy Review Tool\OxygenMRPilot0811_d2.xlsx" 
     "C:\testsas\OxygenMRPilot_&amp;amp;ID..xlsx" ; 
run;
%MEND;

%Macro tool2(ID2);

%exportxl( data=tool1 ,
   outfile= C:\testsas\OxygenMRPilot_&amp;amp;ID2..xlsx,
   Sheet=SMRT,
   Type=M,
   Replace=N,
   useformats=Y);
run;
%MEND Tool2;

%tool(T1-OX3-3081);
%tool2(T1-OX3-3081);

%tool(T1-OX3-3090);
%tool2(T1-OX3-3090);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know it's clunky and not very elegant ... but it works. &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is someone can think of more elegant way to run the code 10,000 times (instead of my having to invoke the two Macros 10,000 times, I'd be super happy. &amp;nbsp;The trick is I need to use the "ID" for naming the resulting files, and not just consequtive numbers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2016 01:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/291622#M16622</guid>
      <dc:creator>Geetu</dc:creator>
      <dc:date>2016-08-15T01:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Output/creating multiple excel documents - with preexisting excel template</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/291625#M16623</link>
      <description>&lt;P&gt;Did you look into call execute?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2016 02:23:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/291625#M16623</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-15T02:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Output/creating multiple excel documents - with preexisting excel template</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/291626#M16624</link>
      <description>&lt;P&gt;I don't understand why you have two macros.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why dont you remove the &amp;nbsp;%mend and &amp;nbsp;%macro in the middle, change ID2 to ID and you have a single macro to be executed 10000 times.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2016 02:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/291626#M16624</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-15T02:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Output/creating multiple excel documents - with preexisting excel template</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/291627#M16625</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Options noxwait noxsync;
%macro Tool(ID);

%sysexec copy "U:\SMRT\Med Review Tool Pilot\Oxy Review Tool\OxygenMRPilot0811_d2.xlsx" 
     "C:\testsas\OxygenMRPilot_&amp;amp;ID..xlsx" ; 
run;


%exportxl( data=TestOxy (Where=(sample_ID="&amp;amp;ID")) ,
   outfile= C:\testsas\OxygenMRPilot_&amp;amp;ID..xlsx,
   Sheet=SMRT,
   Type=M,
   Replace=N,
   useformats=Y);
run;
%MEND;

Data _null_;
Set idlist;

Str = catt('%tool(', id, ');');
Call execute ( Str);

Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Aug 2016 02:40:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/291627#M16625</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-15T02:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: Output/creating multiple excel documents - with preexisting excel template</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/291675#M16626</link>
      <description>&lt;P&gt;You know I did have just one Macro initially ... but it would fail. &amp;nbsp;But I think I had it set up incorrectly in some way (which I now forget!).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But THANK YOU Reeza!!! &amp;nbsp;You've been amazingly helpful and so kind with my slowly grasping the information &amp;nbsp;you've provided. &amp;nbsp;It's nice to re-grease my SAS wheels!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I love your elegent rewrite of my macro, but it doesn't work ... running that code gives me the same error I was seeing last night - the text of the macro is written into the excel document rather than run as code. &amp;nbsp;Weird I know. &amp;nbsp;I think it has to do with timing (?) .. that is, the copy procedure is simply copying over the text of the macro ... rather than the macro getting to execute (if that makes sense).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case, I re-did my Macro ... cleaning it up carefully, and used your tip of creating the _null_ dataset and a call execute to run multiples of IDs ... and voila! Got what I need ... with the testsets of 20 and 60 cases.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So here's my working code now:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Tool(ID);

data tool1;
set testOxy ;
if sample_ID = "&amp;amp;id";
format From_Date To_Date Billed_Date mmddyy10.;
run;

options noxwait noxsync;
%sysexec copy "U:\SMRT\Med Review Tool Pilot\Oxy Review Tool\OxygenMRPilot0811_d2.xlsx" 
     "C:\testsas\Tests_0814\OxygenMRPilot_&amp;amp;ID..xlsx" ; 
run;
%exportxl( data=tool1 ,
   outfile= C:\testsas\Tests_0814\OxygenMRPilot_&amp;amp;ID..xlsx,
   Sheet=SMRT,
   Type=M,
   Replace=N,
   useformats=N);
run;
%MEND Tool;


Data _null_;
Set idlist;

Str = catt('%tool(', id, ');');
Call execute ( Str);

Run;
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Only one odd result ... there's a stack of cmd windows open .. expected .. and they each slowly close as the run gets completed. However, the final cmd window stays open till I manually close it. It doesn't seem to affect the results tho'&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2016 13:28:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Output-creating-multiple-excel-documents-with-preexisting-excel/m-p/291675#M16626</guid>
      <dc:creator>Geetu</dc:creator>
      <dc:date>2016-08-15T13:28:09Z</dc:date>
    </item>
  </channel>
</rss>

