<?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 How to combine 2 excel book into one-can't use proc import due to one file  has color coded in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-2-excel-book-into-one-can-t-use-proc-import-due/m-p/870437#M343795</link>
    <description>&lt;P&gt;Hi Geeks:&lt;/P&gt;
&lt;P&gt;I am trying to figure out&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to combine 2 independent Excel files in One excel. (proc import won't be feasible since one of the excel book has color coded cell)&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Have&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Excel book ABC: Had Sheet A , Sheet B, Sheet C&lt;/P&gt;
&lt;P&gt;Excel book Color &lt;span class="lia-unicode-emoji" title=":anguished_face:"&gt;😧&lt;/span&gt; Had color coded Sheet ColorD&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Want:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Excel book all : Sheet A, Sheet B , Sheet C , Sheet ColorD&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Question:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Is there a way to achieve the goal in SAS?&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800000"&gt;Please see attached&lt;/FONT&gt; &lt;FONT color="#800000"&gt;EXCEL files&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Thank you all,&lt;/P&gt;
&lt;P&gt;purple&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Apr 2023 20:32:22 GMT</pubDate>
    <dc:creator>purpleclothlady</dc:creator>
    <dc:date>2023-04-18T20:32:22Z</dc:date>
    <item>
      <title>How to combine 2 excel book into one-can't use proc import due to one file  has color coded</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-2-excel-book-into-one-can-t-use-proc-import-due/m-p/870437#M343795</link>
      <description>&lt;P&gt;Hi Geeks:&lt;/P&gt;
&lt;P&gt;I am trying to figure out&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to combine 2 independent Excel files in One excel. (proc import won't be feasible since one of the excel book has color coded cell)&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Have&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Excel book ABC: Had Sheet A , Sheet B, Sheet C&lt;/P&gt;
&lt;P&gt;Excel book Color &lt;span class="lia-unicode-emoji" title=":anguished_face:"&gt;😧&lt;/span&gt; Had color coded Sheet ColorD&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Want:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Excel book all : Sheet A, Sheet B , Sheet C , Sheet ColorD&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Question:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Is there a way to achieve the goal in SAS?&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800000"&gt;Please see attached&lt;/FONT&gt; &lt;FONT color="#800000"&gt;EXCEL files&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Thank you all,&lt;/P&gt;
&lt;P&gt;purple&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 20:32:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-2-excel-book-into-one-can-t-use-proc-import-due/m-p/870437#M343795</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2023-04-18T20:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine 2 excel book into one-can't use proc import due to one file  has color coded</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-2-excel-book-into-one-can-t-use-proc-import-due/m-p/870441#M343798</link>
      <description>&lt;P&gt;This looks like a question for a Microsoft Excel site, not SAS.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 21:03:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-2-excel-book-into-one-can-t-use-proc-import-due/m-p/870441#M343798</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-04-18T21:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine 2 excel book into one-can't use proc import due to one file  has color coded</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-2-excel-book-into-one-can-t-use-proc-import-due/m-p/870445#M343800</link>
      <description>&lt;P&gt;If you have Excel, and you want Excel, and aren't doing any calculations, I would leave SAS out of it.&amp;nbsp; If you insert SAS into the middle, you have to deal with SAS trying to decipher the meaning of the all the Excel madness.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to automate combining two Excel files into one file, think about VBA, PowerShell, etc.&amp;nbsp; See e.g.&amp;nbsp;&lt;A href="https://www.ablebits.com/office-addins-blog/merge-multiple-excel-files-into-one/" target="_blank"&gt;https://www.ablebits.com/office-addins-blog/merge-multiple-excel-files-into-one/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course if DDE is still a working thing, and you have PC SAS, then that might let you drive it via SAS, just for fun.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 21:29:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-2-excel-book-into-one-can-t-use-proc-import-due/m-p/870445#M343800</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-04-18T21:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine 2 excel book into one-can't use proc import due to one file  has color coded</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-2-excel-book-into-one-can-t-use-proc-import-due/m-p/870446#M343801</link>
      <description>&lt;P&gt;Check the colour-coded column for an Excel formula to see if one is present to do the colours. If not then then colour-coding must have been done manually.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No doubt there is some business logic underpinning the colour coding. Do you know what that logic is? If there is a colour-coding formula then you should be able to work that out. Once you know the business logic then it is easy to reproduce in SAS if you have the data with which to build the logic.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 21:31:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-2-excel-book-into-one-can-t-use-proc-import-due/m-p/870446#M343801</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-04-18T21:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine 2 excel book into one-can't use proc import due to one file  has color coded</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-2-excel-book-into-one-can-t-use-proc-import-due/m-p/870580#M343840</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&amp;nbsp; all the valuable inputs.&lt;/P&gt;
&lt;P&gt;I figured out the puzzle&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;, Since I didn't tell the whole information, here let me explain. It is all about how to play around with the ods 3 layers with macros.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the coding logic is like this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Goal:&lt;/STRONG&gt; I need to put dataset&amp;nbsp;&lt;EM&gt;A into&amp;nbsp; excel book "colored" AFTER excel sheet "Color D"&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Solution&lt;/STRONG&gt;: see the part3 .&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/*PART1:  Excel Book-A, B, C ....  */
/*-----------------$$MULTIPLE EXCEL BOOKS (3 EXCEL FILES A, B, AND C ) $$
 by using ODS EXCEL FILE= MULTIPLE times.--------------*/

%macro  mul(ds);
      /*1. SAS Steps to create data set A , B ,C*/
      data a;
      data b;
      data c;
%mend mul;
%mul(a);
%mul(b);
%mul(c);

/*2. ODS EXCEL Report to multiple Excel Books*/
ods results off;                       /*---TOP OUTLAYER ---*/    
ods listing close;
ods escapechar = '^';
				
*-----1. A-----; 					
ods excel file="C:\A.xlsx" ;            /*---MIDDLE LAYER 1---*/
 excel options (sheet_name = "A");
    proc report data=A ;
    run;&lt;BR /&gt;					
*-----2. B-----; 					
ods excel file="C:\B.xlsx" ;          /*---MIDDLE  LAYER2 ---*/
 excel options (sheet_name = "B");
    proc report data=B ;
    run;	&lt;BR /&gt;		
*-----3. C-----; 					
ods excel file="C:\C.xlsx" ;           /*---MIDDLE  LAYER3 ---*/
 excel options (sheet_name = "C");
    proc report data=C ;
    run;

ods excel close;                     /*---BOTTOM LAYER ---*/
ods results on;
ods listing;
            
 
/*PART 2:  1 Excel Book-Colored  */
/*------ !! ONE excel book(COLORED) with MULTIPLE SHEETS!!  Color D,Color E,Color F 
by putting the ODS EXCEL FILE =  !OUT! of the %macro color ....--------------*/

ods results off;                            /*---TOP OUTLAYER ---*/
ods listing close;
ods escapechar = '^';
									
ods excel file="c:\Colored.xlsx" ;

%macro  color (ds);                         /*---MIDDLE LAYER */             
/*1. SAS Steps to create colorD*/
/*2. ODS EXCEL Report*/

%if &amp;amp;ds=ColorD %then %do;
      ods excel options (sheet_name = "Color D);
      proc report data=ColorD ;
      run;
%end;
%else %if &amp;amp;ds=ColorE %then %do;
      ods excel options (sheet_name = "Color E);
      proc report data=ColorE ;
      run;
%end;
%else %if &amp;amp;ds=ColorF %then %do;
      ods excel options (sheet_name = "Color F);
      proc report data=ColorF;
      run;
%end;

%mend;
%color(ColorD);
%color(ColorE);
%color(ColorF);

ods excel close;                  /*---BOTTOM LAYER ---*/
ods results on;
ods listing;
&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/*****************SOLUTION*****************/
/*----PART3: Goal-OutPut Dataset A to Excel Book "Colored" AFTER sheet "Color D"------*/ 

/*Part1*/
%macro  mul(ds);
      /*1. SAS Steps to create data set A , B ,C*/
      data a;
      data b;
      data c;
%mend mul;
%mul(a);
%mul(b);
%mul(c);

/*2. ODS EXCEL Report to multiple Excel Books*/
ods results off;                       /*---TOP OUTLAYER ---*/    
ods listing close;
ods escapechar = '^';&lt;BR /&gt;
/*Comment: MOVE  ods excel file="C:/A.xlsx" to part2 from part1*/&lt;BR /&gt;					
*-----2. B-----; 					
ods excel file="C:\B.xlsx" ;          /*---MIDDLE  LAYER2 ---*/
    excel options (sheet_name = "B");
    proc report data=B ;
    run;
			
*-----3. C-----; 					
ods excel file="C:\C.xlsx" ;           /*---MIDDLE  LAYER3 ---*/
    excel options (sheet_name = "C");
    proc report data=C ;
     run;

ods excel close;                     /*---BOTTOM LAYER ---*/
ods results on;
ods listing;
            
/*Part2*/                   
ods results off;                            /*---TOP OUTLAYER ---*/
ods listing close;
ods escapechar = '^';
									
ods excel file="c:\Colored.xlsx" ;

%macro  color (ds);                         /*---MIDDLE LAYER */             
/*1. SAS Steps to create colorD*/
/*2. ODS EXCEL Report*/

%if &amp;amp;ds=ColorD %then %do;
      ods excel options (sheet_name = "ColorD);
      proc report data=ColorD ;
      run;

     /*-------SOLUTION: MOVE ODS EXCEL file="C:\A.xlsx" TO HERE-1. A-------;*/ 					          
        ods excel options  (sheet_name = "A");
        proc report data=A ;
        run;
    /*--------------END OF SOLUTIION--------------------*/
%end;
%else %if &amp;amp;ds=ColorE %then %do;
      ods excel options (sheet_name = "Color E);
      proc report data=ColorE ;
      run;
%end;
%else %if &amp;amp;ds=ColorF %then %do;
      ods excel options (sheet_name = "Color F);
      proc report data=ColorF;
      run;
%end;

%mend;
%color(ColorD);
%color(ColorE);
%color(ColorF);

ods excel close;                  /*---BOTTOM LAYER ---*/
ods results on;
ods listing;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;
&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 15:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-2-excel-book-into-one-can-t-use-proc-import-due/m-p/870580#M343840</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2023-04-19T15:39:57Z</dc:date>
    </item>
  </channel>
</rss>

