<?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: Ignoring specific rows in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Ignoring-specific-rows-in-SAS/m-p/789011#M252415</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/411974"&gt;@rsuresh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;I have a large excel file that I am importing to SAS; Row 1 has the variable names but rows 2-4 of the file have additional descriptive information (about the variables) that I do not want in my SAS dataset. Is there a way to exclude those 3 rows while importing or after importing the data onto SAS?&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You are in luck.&amp;nbsp; The quirky way that the DATAROW= statement works in PROC IMPORT with the XLSX db engine will do exactly that.&amp;nbsp; You can tell it what row to start reading the data, but it always uses the first row to guess what names to give to the variables.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile='large.xlsx' dbms=xlsx
  out=want replace
;
  datarow=5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the extra information was in rows 1 to 3 and row 4 had the column headers then you would have to work harder.&lt;/P&gt;
&lt;P&gt;Example program:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile='c:\downloads\skip.xlsx' dbms=xlsx
  out=skip replace
;
  datarow=3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Obs    X             Y    Z

 1     1    12/31/2021    Height
&lt;/PRE&gt;
&lt;P&gt;Picture of XLSX file:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-01-07 215026.jpg" style="width: 297px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67220i70A27BFB70223BB5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2022-01-07 215026.jpg" alt="Screenshot 2022-01-07 215026.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 08 Jan 2022 02:51:00 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-01-08T02:51:00Z</dc:date>
    <item>
      <title>Ignoring specific rows in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignoring-specific-rows-in-SAS/m-p/788969#M252391</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have a large excel file that I am importing to SAS; Row 1 has the variable names but rows 2-4 of the file have additional descriptive information (about the variables) that I do not want in my SAS dataset. Is there a way to exclude those 3 rows while importing or after importing the data onto SAS?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 21:32:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignoring-specific-rows-in-SAS/m-p/788969#M252391</guid>
      <dc:creator>rsuresh</dc:creator>
      <dc:date>2022-01-07T21:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: Ignoring specific rows in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignoring-specific-rows-in-SAS/m-p/788970#M252392</link>
      <description>&lt;P&gt;Best thing is to remove these rows in Excel.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 21:33:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignoring-specific-rows-in-SAS/m-p/788970#M252392</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-07T21:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: Ignoring specific rows in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignoring-specific-rows-in-SAS/m-p/788982#M252403</link>
      <description>&lt;P&gt;If you are going to have multiple files with the&lt;STRONG&gt; same structure&lt;/STRONG&gt; then one approach is to save the file to a CSV file format and write a data step to read the file.&lt;/P&gt;
&lt;P&gt;The Infile statement that is used by the data step to identify the file and characteristics such as delimiters and logical record length include a FIRSTOBS option which means skip to the row of the file before attempting to read anything.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One big reason to use the CSV approach with multiple files is so you control the type and length of all the variables. Proc Import, or any wizard that uses such, makes separate decisions for each file imported. Which means that variables of the same name may change type or length from different files. Or in a poor data source environment may even mean that the variable names change. The code to read CSV would treat the columns in order the same for each file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you save your file to CSV and use Proc Import for that file (recommend the guessingrows=max; option) then SAS will create data step code that appears in the log. You can copy that code to the editor, clean it up save and reuse. &lt;BR /&gt;This will work better with a file without extra information as you describe. Once you have a nice program to read the file you can add the option for Firstobs to skip the header rows for the next file.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 22:53:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignoring-specific-rows-in-SAS/m-p/788982#M252403</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-01-07T22:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Ignoring specific rows in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignoring-specific-rows-in-SAS/m-p/789011#M252415</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/411974"&gt;@rsuresh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;I have a large excel file that I am importing to SAS; Row 1 has the variable names but rows 2-4 of the file have additional descriptive information (about the variables) that I do not want in my SAS dataset. Is there a way to exclude those 3 rows while importing or after importing the data onto SAS?&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You are in luck.&amp;nbsp; The quirky way that the DATAROW= statement works in PROC IMPORT with the XLSX db engine will do exactly that.&amp;nbsp; You can tell it what row to start reading the data, but it always uses the first row to guess what names to give to the variables.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile='large.xlsx' dbms=xlsx
  out=want replace
;
  datarow=5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the extra information was in rows 1 to 3 and row 4 had the column headers then you would have to work harder.&lt;/P&gt;
&lt;P&gt;Example program:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile='c:\downloads\skip.xlsx' dbms=xlsx
  out=skip replace
;
  datarow=3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Obs    X             Y    Z

 1     1    12/31/2021    Height
&lt;/PRE&gt;
&lt;P&gt;Picture of XLSX file:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-01-07 215026.jpg" style="width: 297px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67220i70A27BFB70223BB5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2022-01-07 215026.jpg" alt="Screenshot 2022-01-07 215026.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jan 2022 02:51:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignoring-specific-rows-in-SAS/m-p/789011#M252415</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-08T02:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Ignoring specific rows in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignoring-specific-rows-in-SAS/m-p/789394#M252591</link>
      <description>This worked perfectly, thank you so much!</description>
      <pubDate>Tue, 11 Jan 2022 03:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignoring-specific-rows-in-SAS/m-p/789394#M252591</guid>
      <dc:creator>rsuresh</dc:creator>
      <dc:date>2022-01-11T03:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Ignoring specific rows in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignoring-specific-rows-in-SAS/m-p/789396#M252593</link>
      <description>Unfortunately, I have multiple files and most of them have varying formats for themselves and the sheets within as well.</description>
      <pubDate>Tue, 11 Jan 2022 03:19:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignoring-specific-rows-in-SAS/m-p/789396#M252593</guid>
      <dc:creator>rsuresh</dc:creator>
      <dc:date>2022-01-11T03:19:34Z</dc:date>
    </item>
  </channel>
</rss>

