<?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 issue: no data in first 5 records in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348907#M273500</link>
    <description>&lt;P&gt;Oops I copy and pasted wrong, I do have the double quote around the file location.&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; _null_&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token statement"&gt;infile&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'D:\nosocomial\27-mar-2017.csv'&lt;/SPAN&gt; obs&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;5&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  list&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I ran this and log displays:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: The infile "D:\Nosocomial\27-Mar-2017 Screening Data.csv" is:&lt;BR /&gt;Filename=D:\Nosocomial\27-Mar-2017 Screening Data.csv,&lt;BR /&gt;RECFM=V,LRECL=32767,File Size (bytes)=123016,&lt;BR /&gt;Last Modified=10Apr2017:13:19:40,&lt;BR /&gt;Create Time=10Apr2017:13:19:41&lt;/P&gt;
&lt;P&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9--&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;EDIT: Data stripped due to suspected confidentiality issues (@reeza)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;NOTE: 1 record was read from the infile "D:\Nosocomial\27-Mar-2017 Screening Data.csv".&lt;BR /&gt;The minimum record length was 32767.&lt;BR /&gt;The maximum record length was 32767.&lt;BR /&gt;One or more lines were truncated.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.65 seconds&lt;BR /&gt;cpu time 0.43 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Apr 2017 22:33:22 GMT</pubDate>
    <dc:creator>michan22</dc:creator>
    <dc:date>2017-04-10T22:33:22Z</dc:date>
    <item>
      <title>importing issue: no data in first 5 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348903#M273497</link>
      <description>&lt;P&gt;Hi guys!&lt;/P&gt;&lt;P&gt;I am trying to import a csv file and here is my import code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc import out=qiao.pepfar&lt;/P&gt;&lt;P&gt;datafile='D:\nosocomial\27-mar-2017.csv&lt;/P&gt;&lt;P&gt;dbms=csv replace;&lt;/P&gt;&lt;P&gt;getnames=yes;&lt;/P&gt;&lt;P&gt;guessingrows=700;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;log says: unable to sample external file. no data in first 5 records.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I searched previous post for similar problems and seems like the response from most people is to check the csv file for missing data in the first 5 rows. I did check and there are no empty rows anywhere in my csv file.&lt;/P&gt;&lt;P&gt;Does anyone know what's the problem here?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 21:55:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348903#M273497</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2017-04-10T21:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: importing issue: no data in first 5 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348904#M273498</link>
      <description>&lt;P&gt;Your posted code is missing a closing quote. &amp;nbsp;Is it possible that is your problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is in the first five rows of the file? Here is simple program you can use to look.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile 'D:\nosocomial\27-mar-2017.csv' obs=5 ;
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Apr 2017 22:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348904#M273498</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-10T22:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: importing issue: no data in first 5 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348905#M273499</link>
      <description>&lt;P&gt;Missing ' in the csv file name perhaps.&lt;/P&gt;
&lt;P&gt;That is if the code shown was copied correctly.&lt;/P&gt;
&lt;P&gt;Or other misspelling in the file name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also when checking CSV files do &lt;STRONG&gt;not&lt;/STRONG&gt; use Excel, use a text editor. Excel will often hide some format issues and make you believe there is no problem when there is.&lt;/P&gt;
&lt;P&gt;Use notepad, Wordpad or even the SAS program editor to look at the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 22:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348905#M273499</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-10T22:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: importing issue: no data in first 5 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348907#M273500</link>
      <description>&lt;P&gt;Oops I copy and pasted wrong, I do have the double quote around the file location.&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; _null_&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token statement"&gt;infile&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'D:\nosocomial\27-mar-2017.csv'&lt;/SPAN&gt; obs&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;5&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  list&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I ran this and log displays:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: The infile "D:\Nosocomial\27-Mar-2017 Screening Data.csv" is:&lt;BR /&gt;Filename=D:\Nosocomial\27-Mar-2017 Screening Data.csv,&lt;BR /&gt;RECFM=V,LRECL=32767,File Size (bytes)=123016,&lt;BR /&gt;Last Modified=10Apr2017:13:19:40,&lt;BR /&gt;Create Time=10Apr2017:13:19:41&lt;/P&gt;
&lt;P&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9--&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;EDIT: Data stripped due to suspected confidentiality issues (@reeza)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;NOTE: 1 record was read from the infile "D:\Nosocomial\27-Mar-2017 Screening Data.csv".&lt;BR /&gt;The minimum record length was 32767.&lt;BR /&gt;The maximum record length was 32767.&lt;BR /&gt;One or more lines were truncated.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.65 seconds&lt;BR /&gt;cpu time 0.43 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 22:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348907#M273500</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2017-04-10T22:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: importing issue: no data in first 5 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348908#M273501</link>
      <description>&lt;P&gt;Sorry that was a copy paste error, I did have both quote around the file location.&lt;/P&gt;&lt;P&gt;I checked my file in notepad and it does not seem like any row is empty.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 23:38:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348908#M273501</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2017-04-10T23:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: importing issue: no data in first 5 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348919#M273502</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/135827"&gt;@michan22&lt;/a&gt;&amp;nbsp;Is this public information? If it's private I would highly suggest you delete it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 22:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348919#M273502</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-10T22:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: importing issue: no data in first 5 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348921#M273503</link>
      <description>&lt;P&gt;This bit from your log&lt;/P&gt;
&lt;PRE&gt;The minimum record length was 32767.
The maximum record length was 32767.&lt;BR /&gt;One or more lines were truncated.&lt;/PRE&gt;
&lt;P&gt;May be a big clue. Do you expect any single line to be more than 32767 characters long? There may not be an end of line character that your program is recognizing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you know if this file may have every crossed operating systems such as began on Unix or Apple&amp;nbsp;and you are reading it in Windows?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 23:00:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348921#M273503</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-10T23:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: importing issue: no data in first 5 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348922#M273504</link>
      <description>&lt;P&gt;Looks like your end of lines are not being recognized by SAS. So it thinks that there is only one line. That is why it does not see any data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look at the HEX CODE for the character right after the last character of the last variable name.&lt;/P&gt;
&lt;P&gt;If should be either '0D'x, '0A'x or possible both '0D0A'x.&lt;/P&gt;
&lt;P&gt;Since SAS should automatically recognize the last two (even if some times it thinks the CR is part of the line instead of part of end of line marker) I suspect that you have just CR between the lines.&lt;/P&gt;
&lt;P&gt;Try using the TERMSTR=CR option on your INFILE statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile 'D:\nosocomial\27-mar-2017.csv' obs=2 termstr=cr ;
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is usually caused by writing an Excel file to CSV format when running Excel on a Macintosh. &amp;nbsp;Excel never got the message that Apple switched to Unix log ago and they should use LF as the end of line.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get it to work with PROC IMPORT you will need to use a FILENAME statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename mycsv 'D:\nosocomial\27-mar-2017.csv' termstr=cr ;
proc import datafile=mycsv ....
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 23:07:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348922#M273504</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-10T23:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: importing issue: no data in first 5 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348929#M273505</link>
      <description>&lt;P&gt;There is definitely no variable with more than 32767 characters long.&lt;/P&gt;&lt;P&gt;However, it was an excel file and I saved as csv file on a mac. Then I transfered the file to my windows laptop and imported in sas. Do you think that's the issue?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 23:44:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348929#M273505</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2017-04-10T23:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: importing issue: no data in first 5 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348930#M273506</link>
      <description>&lt;P&gt;Yes. Excel on Mac is stupid. When you save to CSV make sure you pick the right file type. The default CSV file type uses carriage return for end of line. &amp;nbsp;Nobody uses CR for end of line since Apple switch MAC OS to being a flavor of Unix many years ago. &amp;nbsp;Make sure to pick a CSV file type hat will use a normal end of line character when saving to CSV using Excel on a Mac.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 23:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/348930#M273506</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-10T23:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: importing issue: no data in first 5 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/349091#M273507</link>
      <description>&lt;P&gt;That is really weird . Did you try datarow=5 option ?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 13:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/349091#M273507</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-11T13:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: importing issue: no data in first 5 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/349202#M273508</link>
      <description>&lt;P&gt;Thank you! I will try to save as csv file on the PC and let you know if the problem is fixed!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 17:26:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/349202#M273508</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2017-04-11T17:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: importing issue: no data in first 5 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/351005#M273509</link>
      <description>&lt;P&gt;Thank you! I tried to save the file as csv on the PC and it imported fine.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 19:30:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/351005#M273509</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2017-04-18T19:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: importing issue: no data in first 5 records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/351007#M273510</link>
      <description>&lt;P&gt;Good to know. &amp;nbsp;But you could have read the file with the CR at the end of the line by using the TERMSTR option on INFILE or FILENAME statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/14/178.html" target="_blank"&gt;http://support.sas.com/kb/14/178.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 19:34:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-issue-no-data-in-first-5-records/m-p/351007#M273510</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-18T19:34:44Z</dc:date>
    </item>
  </channel>
</rss>

