<?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: Importing and combining excel workbooks in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-and-combining-excel-workbooks-in-SAS/m-p/818801#M323219</link>
    <description>&lt;P&gt;You could try just combining the datasets instead of trying to use PROC APPEND.&lt;/P&gt;
&lt;P&gt;That will allow the addition of new variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data out;
  set out _test;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But with PROC IMPORT you could also have other issues.&lt;/P&gt;
&lt;P&gt;Similarly named variables might be of different types.&lt;/P&gt;
&lt;P&gt;Character variables might have different lengths.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To properly deal with that programmatically you would need to save the individual imported dataset and compare the metadata (variables and their type, length and attached formats) to determine if any need to have their type changed to make combining possible.&amp;nbsp; And to calculate the proper length for character variables to avoid truncation of data.&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jun 2022 11:57:33 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-06-17T11:57:33Z</dc:date>
    <item>
      <title>Importing and combining excel workbooks in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-and-combining-excel-workbooks-in-SAS/m-p/818756#M323196</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am fairly new to SAS and could really use some help with the following please:&lt;/P&gt;&lt;P&gt;I have 3 excel workbooks (not sheets in 1 workbook) and I need to make them into a single SAS data table if possible. One catch is that the workbooks have some columns that have the same data (headings and data is the same), but also some unique columns (present in only one workbook and not the others). When I try the below code, I get a whole bunch of warnings "...was not found in base. The variable will not be added to the BASE file."&lt;/P&gt;&lt;P&gt;Ideally I'd like to have the new data from workbook 2,3,4 etc.. be added to the data table, and in the case that some of the data is duplicated have a way of only showing it once in the data table, is that possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro MultImp(dir=,out=);&lt;/P&gt;&lt;P&gt;%let rc=%str(%'dir %")&amp;amp;dir.%str(\%" /A-D/B/ON%');&lt;BR /&gt;filename myfiles pipe %unquote(&amp;amp;rc);&lt;/P&gt;&lt;P&gt;data list;&lt;BR /&gt;length fname $256.;&lt;BR /&gt;infile myfiles truncover;&lt;BR /&gt;input myfiles $100.;&lt;/P&gt;&lt;P&gt;fname=quote(upcase(cats("&amp;amp;dir",'\',myfiles)));&lt;BR /&gt;out="&amp;amp;out";&lt;BR /&gt;drop myfiles;&lt;BR /&gt;call execute('&lt;BR /&gt;proc import dbms=xlsx out= _test&lt;BR /&gt;datafile= '||fname||' replace ;&lt;BR /&gt;run;&lt;BR /&gt;proc append data=_test base='||out||' force; run;&lt;BR /&gt;proc delete data=_test; run;&lt;BR /&gt;');&lt;BR /&gt;run;&lt;BR /&gt;filename myfiles clear;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%MultImp(dir=file containing excel files,out=merged);&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 08:18:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-and-combining-excel-workbooks-in-SAS/m-p/818756#M323196</guid>
      <dc:creator>2222</dc:creator>
      <dc:date>2022-06-17T08:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: Importing and combining excel workbooks in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-and-combining-excel-workbooks-in-SAS/m-p/818794#M323213</link>
      <description>&lt;P&gt;It seems as if your question boils down to the ability of PROC APPEND to actually append these files. (I haven't checked the rest of your macro)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to the PROC APPEND &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/n19kwc3onglzh2n1l2k4e39edv3x.htm#n038h2uiajghepn1diwi0r61ihqq" target="_self"&gt;documentation&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;H3 id="n038h2uiajghepn1diwi0r61ihqq" class="xisDoc-title" tabindex="-1"&gt;Appending to Data Sets with Different Variables&lt;/H3&gt;
&lt;P class="xisDoc-paragraph"&gt;If the DATA= data set contains variables that are not in the BASE= data set, use the FORCE option in the APPEND statement to force the concatenation of the two data sets. The APPEND statement drops the extra variables and issues a warning message. You can use the NOWARN option to suppress the warning message.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P class="xisDoc-paragraph"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="xisDoc-paragraph"&gt;So, you can't use PROC APPEND in this case. You would need to do the append in a DATA step.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 11:32:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-and-combining-excel-workbooks-in-SAS/m-p/818794#M323213</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-17T11:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: Importing and combining excel workbooks in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-and-combining-excel-workbooks-in-SAS/m-p/818801#M323219</link>
      <description>&lt;P&gt;You could try just combining the datasets instead of trying to use PROC APPEND.&lt;/P&gt;
&lt;P&gt;That will allow the addition of new variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data out;
  set out _test;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But with PROC IMPORT you could also have other issues.&lt;/P&gt;
&lt;P&gt;Similarly named variables might be of different types.&lt;/P&gt;
&lt;P&gt;Character variables might have different lengths.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To properly deal with that programmatically you would need to save the individual imported dataset and compare the metadata (variables and their type, length and attached formats) to determine if any need to have their type changed to make combining possible.&amp;nbsp; And to calculate the proper length for character variables to avoid truncation of data.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 11:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-and-combining-excel-workbooks-in-SAS/m-p/818801#M323219</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-17T11:57:33Z</dc:date>
    </item>
  </channel>
</rss>

