<?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: How to import complex xls tables into SAS in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801519#M33224</link>
    <description>&lt;P&gt;Thanks. How do I do that? I have multiples files with multiples tables with the same structure.&lt;/P&gt;</description>
    <pubDate>Thu, 10 Mar 2022 21:36:49 GMT</pubDate>
    <dc:creator>Didi_b</dc:creator>
    <dc:date>2022-03-10T21:36:49Z</dc:date>
    <item>
      <title>How to import complex xls tables into SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801496#M33217</link>
      <description>&lt;P&gt;&amp;nbsp;Hello, I have complex xls daily data tables from several years for example from 2000 to 2019 in a file. Unfortunately, the data tables have text above and below the data. Also, the name row, start row and end row are not same. However the variables name are the same as well as the structure of the table. I try a macro program by specing the name and start rows, but since all the tables don't have the same name et start row, and regarding the text above, I am looking for a solution to import all the tables at once with the text removed (at least the one above). I'm asking because it is a lot of tables to work on it one by one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below a copy of different tables (I'll post as a response) and a copy of my macro for tables with the same start and name row, I tested with the help from the SAS communities. Need your help, please.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;
%macro import(T01);
FILENAME REFFILE "Z:\tune\BAD\FAC\T01\&amp;amp;T01..xls";

proc import datafile=reffile dbms=xls out=%sysfunc(compress(&amp;amp;T01. , "- ")) replace;
sheet="XTH";
namerow=7;
startrow=10;
*Endrow=934 (the end rows are not the same for each table;
getnames=yes;
run;

%mend import;

%import (CalT_glob_2018-01-15);
%import (CalT_glob_2019-03-20);
/*etc.*/
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Mar 2022 20:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801496#M33217</guid>
      <dc:creator>Didi_b</dc:creator>
      <dc:date>2022-03-10T20:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to import complex xls tables into SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801501#M33218</link>
      <description>&lt;P&gt;Here an example of the different tables (It is not the names neither the real data because I’m not allowed to)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 20:46:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801501#M33218</guid>
      <dc:creator>Didi_b</dc:creator>
      <dc:date>2022-03-17T20:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to import complex xls tables into SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801505#M33219</link>
      <description>&lt;P&gt;Try something like this to determine the start and end of the table part of the sheet.&lt;/P&gt;
&lt;P&gt;Read in the file without trying to generate variable names.&lt;/P&gt;
&lt;P&gt;Then check the first column to see where the row header is and where the footnote is.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro import(T01);
FILENAME REFFILE "Z:\tune\BAD\FAC\T01\&amp;amp;T01..xls";
proc import datafile=reffile out=raw replace dbms=XLS;
  sheet="XTH";
  startcol=1;
  endcol=1;
  getnames=no;
run;
data _null_;
  set raw;
  if 'NAME'=upcase(strip(A)) then call symputx('startrow',_n_);
  if A ne ' ' and left(A)=:'**' then call symputx('endrow',cats('endrow=',_n_));
run;
proc import datafile=reffile dbms=xls out=%sysfunc(compress(&amp;amp;T01. , "- ")) replace;
sheet="XTH";
  startrow=&amp;amp;startrow;
  &amp;amp;endrow;
  getnames=yes;
run;

%mend import;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here are the statements that work with XLS engine.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acpcref/n0msy4hy1so0ren1acm90iijxn8j.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acpcref/n0msy4hy1so0ren1acm90iijxn8j.htm&lt;/A&gt;&lt;/P&gt;
&lt;TABLE id="p0bwg4yiuv5iunn1luzdzc4bd9ls" class="xisDoc-tgroup5 xisDoc-table"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-verticalTop"&gt;
&lt;P class="xisDoc-paragraph"&gt;DBMS= Identifier&lt;/P&gt;
&lt;/TH&gt;
&lt;TH class="xisDoc-verticalTop"&gt;
&lt;P class="xisDoc-paragraph"&gt;Option&lt;/P&gt;
&lt;/TH&gt;
&lt;TH class="xisDoc-verticalTop"&gt;
&lt;P class="xisDoc-paragraph"&gt;Valid Value&lt;/P&gt;
&lt;/TH&gt;
&lt;TH class="xisDoc-verticalTop"&gt;
&lt;P class="xisDoc-paragraph"&gt;Default Value&lt;/P&gt;
&lt;/TH&gt;
&lt;TH class="xisDoc-verticalTop"&gt;
&lt;P class="xisDoc-paragraph"&gt;PROC&lt;/P&gt;
&lt;P class="xisDoc-paragraph"&gt;IMPORT&lt;/P&gt;
&lt;/TH&gt;
&lt;TH class="xisDoc-verticalTop"&gt;
&lt;P class="xisDoc-paragraph"&gt;PROC&lt;/P&gt;
&lt;P class="xisDoc-paragraph"&gt;EXPORT&lt;/P&gt;
&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-forScope" rowspan="11" scope="row"&gt;
&lt;P class="xisDoc-paragraph"&gt;XLS&lt;/P&gt;
&lt;/TH&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;ENDCOL&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Last column for data&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Last column that contains data&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;No&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;ENDNAMEROW&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Last row for variable names&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Same as NAMEROW&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;No&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;ENDROW&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Last row for data&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Last row that contains data&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;No&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;GETNAMES&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes | No&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;No&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;NAMEROW&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;First row for variable names&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;First row that contains variable names&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;No&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;NEWFILE&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes | No&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;No&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;No&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;PUTNAMES&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes | No&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;No&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;RANGE&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;name | sheet$ul:lr&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;First row&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;No&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;SHEET&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Sheet name&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;First sheet&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;STARTCOL&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;First column for data&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Last column that contains data&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;No&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;STARTROW&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;First row for data&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;First row that contains data&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;Yes&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P class="xisDoc-paragraph"&gt;No&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Thu, 10 Mar 2022 20:50:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801505#M33219</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-10T20:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to import complex xls tables into SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801507#M33220</link>
      <description>&lt;P&gt;What would you want a SAS dataset of one of your tables to look like? For example your tables have subtotal and total rows. Typically a SAS dataset is just detail rows from which a tabular report can be created with subtotals and total rows calculated on the fly.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 20:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801507#M33220</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-03-10T20:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to import complex xls tables into SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801515#M33221</link>
      <description>&lt;P&gt;Thanks Tom. I still get the table with the text below and above&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Log result:


1    %macro import(T01);
2    FILENAME REFFILE "filepath\&amp;amp;T01..xls";
3    proc import datafile=reffile out=raw replace dbms=XLS;
4      sheet="XTH";
5      getnames=no;
6    run;
7    data _null_;
8      set raw;
9      if 'NAME'=upcase(strip(A)) then call symputx('startrow',_n_);
10     if A ne ' ' and left(A)=:'**' then call symputx('endrow',cats('endrow=',_n_));
11   run;
12   proc import datafile=reffile dbms=xls out=%sysfunc(compress(&amp;amp;T01. , "- ")) replace;
13   sheet="XTH";
14     namerow=&amp;amp;startrow;
15     &amp;amp;endrow;
16     getnames=yes;
17   run;
18
19   %mend import;
20
21   %import (file1name);

NOTE: The import data set has 34 observations and 12 variables.
NOTE: WORK.RAW data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.09 seconds
      cpu time            0.01 seconds



NOTE: There were 34 observations read from the data set WORK.RAW.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds



NOTE:    Variable Name Change.  Ré -&amp;gt; R_
NOTE:    Variable Name Change.  Ti Ré -&amp;gt; Ti_R_
NOTE:    Variable Name Change.  Ti max -&amp;gt; Ti_max
NOTE: The import data set has 33 observations and 12 variables.
NOTE: WORK.table1name data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.20 seconds
      cpu time            0.00 seconds


22   %import (file2name);

NOTE: The import data set has 31 observations and 9 variables.
NOTE: WORK.RAW data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds



NOTE: There were 31 observations read from the data set WORK.RAW.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds



NOTE:    Variable Name Change.  
Ré -&amp;gt; _R_
NOTE:    Variable Name Change.  Ti Ré -&amp;gt; Ti_R_
NOTE:    Variable Name Change.  Ti max -&amp;gt; Ti_max
NOTE: The import data set has 30 observations and 9 variables.
NOTE: WORK.table2name data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.21 seconds
      cpu time            0.03 seconds


23   %import (file3name)

NOTE: The import data set has 47 observations and 14 variables.
NOTE: WORK.RAW data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds



NOTE: There were 47 observations read from the data set WORK.RAW.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


WARNING: Apparent symbolic reference ENDROW not resolved.
NOTE: Line generated by the invoked macro "IMPORT".
2     ' ' and left(A)=:'**' then call symputx('endrow',cats('endrow=',_n_)); run; proc import
2  ! datafile=reffile dbms=xls out=%sysfunc(compress(&amp;amp;T01. , "- ")) replace; sheet="XTH";
2  ! namerow=&amp;amp;startrow;   &amp;amp;endrow;   getnames=yes; run;
                          -
                          180
ERROR 180-322: Statement is not valid or it is used out of proper order.

NOTE: The previous statement has been deleted.
NOTE: The previous statement has been deleted.


NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds

24   /*etc.*/
25   run;

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 20:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801515#M33221</guid>
      <dc:creator>Didi_b</dc:creator>
      <dc:date>2022-03-17T20:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to import complex xls tables into SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801516#M33222</link>
      <description>&lt;P&gt;If the files are truly complex then SAVE the data as a text file.&lt;/P&gt;
&lt;P&gt;Write a data step to read the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Import, especially with many files, can result in all sorts of garbage variables because of multiple line headers and row or column spanning cells. Different files that should have the same structure will end up with different lengths of variables and can well have variables change types from numeric to character. The data step, while it takes some time to write will be consistent and has many more tools to deal with problem cases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With a data step you set the constant properties for the variables, such as type and length. Then to read different files you change the input file name and maybe the output data set name.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 21:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801516#M33222</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-10T21:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to import complex xls tables into SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801517#M33223</link>
      <description>&lt;P&gt;I would like to have a normal table at the end. I prepar the code to delete the sub total and total, and also code to file the void on variables name and date. I just ned to find a way to import all my tables at once because it is a lot (daily table on more than 7 years)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; 
set Work.have;

if Day="" then Day='12/01/2022';
if Day="Sous Total" then delete;
else Day='12/01/2022';

NDay=input(Day,MMDDYY10.);
format NDay MMDDYY10.;

Nhour=input(translate(hour,':','H'),time15.);
format NHour tod5.;

retain File;
if not missing(Name) then File=Name;
else Name=File;
drop File Day hour;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Mar 2022 21:29:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801517#M33223</guid>
      <dc:creator>Didi_b</dc:creator>
      <dc:date>2022-03-10T21:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to import complex xls tables into SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801519#M33224</link>
      <description>&lt;P&gt;Thanks. How do I do that? I have multiples files with multiples tables with the same structure.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 21:36:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801519#M33224</guid>
      <dc:creator>Didi_b</dc:creator>
      <dc:date>2022-03-10T21:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to import complex xls tables into SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801523#M33225</link>
      <description>&lt;P&gt;Get it to work for ONE table before trying to make a macro to generalize it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a working example.&lt;/P&gt;
&lt;P&gt;I created an XLS file with junk at top and bottom and a 3 column table in the middle.&lt;/P&gt;
&lt;P&gt;So this code reads the first column.&amp;nbsp; Checks it to find the start and stop column for the table. Then uses that to build the RANGE to give to PROC IMPORT.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path=c:\downloads;
%let fname=spanrows.xls;

proc import datafile="&amp;amp;path/&amp;amp;fname" dbms=xls out=raw replace;
  getnames=no;
  startcol='A';
  endcol='A';
run;

data _null_;
  set raw;
  if upcase(strip(A))='NAME' then call symputx('startrow',_n_);
  if left(A)=:'**' then call symputx('endrow',_n_-1);
run;

proc import datafile="&amp;amp;path/&amp;amp;fname" dbms=xls out=want replace;
  getnames=yes;
  range="$A&amp;amp;startrow:C&amp;amp;endrow";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;Obs    NAME                     DAY           VALUE

 1     ABC                        1              34
 2                                2              56
 3                                3              78
 4                                4             101
 5     ABC                        1              34
 6                                2              56
 7                                3              78
 8                                4             101
&lt;/PRE&gt;
&lt;P&gt;Finding a method to carry the NAME values from the merged cells forward I will leave as an exercise.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 21:48:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801523#M33225</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-10T21:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to import complex xls tables into SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801525#M33226</link>
      <description>&lt;P&gt;I'll work on it, and see what I can do with your proposition. Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 21:47:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801525#M33226</guid>
      <dc:creator>Didi_b</dc:creator>
      <dc:date>2022-03-10T21:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to import complex xls tables into SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801742#M33232</link>
      <description>&lt;P&gt;This program works with one table. I'm trying the macro one and still on it.&lt;/P&gt;
&lt;P&gt;I'll let you know if I find my way. Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2022 21:06:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-import-complex-xls-tables-into-SAS/m-p/801742#M33232</guid>
      <dc:creator>Didi_b</dc:creator>
      <dc:date>2022-03-11T21:06:18Z</dc:date>
    </item>
  </channel>
</rss>

