<?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 a File in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-File/m-p/406360#M279303</link>
    <description>&lt;P&gt;Chris,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your file contains text fields with embedded line breaks. That's what throws of proc import. A very common thing to happen.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many examples have been given in this forum to deal with that. Have a look to see if any fits your needs (often but not always the termstr option on the filename statement helps). All I can do now is to let you now. I am not in a position now to experiment with this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;</description>
    <pubDate>Sun, 22 Oct 2017 11:39:56 GMT</pubDate>
    <dc:creator>jklaverstijn</dc:creator>
    <dc:date>2017-10-22T11:39:56Z</dc:date>
    <item>
      <title>Importing a File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-File/m-p/406356#M279302</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have run the code below to bring in a file via an API:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;filename&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;resp&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;TEMP&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;options&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;validvarname&lt;/SPAN&gt;&lt;SPAN&gt;=any;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;STRONG&gt;&lt;SPAN&gt;proc&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;http&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;url=&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;A href="https://api.diffbot.com/v3/crawl/data?token=*************************&amp;amp;name=freshfields_ex&amp;amp;format=csv&amp;amp;num=2000000" target="_blank"&gt;https://api.diffbot.com/v3/crawl/data?token=*************************&amp;amp;name=freshfields_ex&amp;amp;format=csv&amp;amp;num=2000000&lt;/A&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;out=resp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;STRONG&gt;&lt;SPAN&gt;run&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;STRONG&gt;&lt;SPAN&gt;proc&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;file&lt;/SPAN&gt;&lt;SPAN&gt;=resp&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;out&lt;/SPAN&gt;&lt;SPAN&gt;=work.resp replace&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;dbms&lt;/SPAN&gt;&lt;SPAN&gt;=csv;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;getnames&lt;/SPAN&gt;&lt;SPAN&gt;=yes;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;STRONG&gt;&lt;SPAN&gt;run&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;I have starred out my password but the file that I import is attached instead. The problem is when I try to import it into SAS. The file doesn't translate into a structured file. The columns should be type, description, diffbotUri, emailAddress, experience, name,office, pageUrl, practiceArea, professionalLevel. The columns and rows on the imported table are all out of synch.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;Please could you help me to import it. The file is a "file" extension.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Chris&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2017 11:12:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-File/m-p/406356#M279302</guid>
      <dc:creator>cmoore</dc:creator>
      <dc:date>2017-10-22T11:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-File/m-p/406360#M279303</link>
      <description>&lt;P&gt;Chris,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your file contains text fields with embedded line breaks. That's what throws of proc import. A very common thing to happen.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many examples have been given in this forum to deal with that. Have a look to see if any fits your needs (often but not always the termstr option on the filename statement helps). All I can do now is to let you now. I am not in a position now to experiment with this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2017 11:39:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-File/m-p/406360#M279303</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2017-10-22T11:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-File/m-p/406389#M279304</link>
      <description>&lt;P&gt;Your file appears to contain Unicode characters. Make sure you are using utf-8 encoding and not something like latin1 or wlatin1 that cannot represent all possible unicode characters.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2017 19:39:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-File/m-p/406389#M279304</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-22T19:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-File/m-p/406391#M279305</link>
      <description>&lt;P&gt;You cannot embed line breaks in the middle of a value.&amp;nbsp; It looks like your file does that, but it does add quotes around the fields that have the embedded line breaks, so you should be able to fix them.&amp;nbsp; See this thread.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/Carriage-Returns-Need-to-be-removed/td-p/83079" target="_blank"&gt;https://communities.sas.com/t5/General-SAS-Programming/Carriage-Returns-Need-to-be-removed/td-p/83079&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Looks like your file should have only 1,613 lines instead of the 8,333 that it currently has.&lt;/P&gt;
&lt;PRE&gt;48    data _null_ ;
49      if eof then put 'NOTE: Records read=' newn 'Records with missing quotes=' missq ;
50      infile old lrecl=10000 end=eof ;
51      file new lrecl=100000;
52      nq=0;
53      do until (mod(nq,2)=0 or eof );
54         input;
55         newn+1;
56         nq = nq + countc(_infile_,'"');
57         put _infile_ @;
58         if mod(nq,2) then do;
59           missq+1;
60           put '|' @;
61         end;
62      end;
63      put;
64    run;

NOTE: The infile OLD is:
      Filename=c:\downloads\sample.csv,
      RECFM=V,LRECL=10000,File Size (bytes)=1736314,
      Last Modified=22Oct2017:11:42:34,
      Create Time=22Oct2017:15:42:18

NOTE: The file NEW is:
      Filename=c:\downloads\fixed.csv,
      RECFM=V,LRECL=100000,File Size (bytes)=0,
      Last Modified=22Oct2017:15:57:31,
      Create Time=22Oct2017:15:56:08

NOTE: Records read=8333 Records with missing quotes=6720
NOTE: 8333 records were read from the infile OLD.
      The minimum record length was 0.
      The maximum record length was 1056.
NOTE: 1613 records were written to the file NEW.
      The minimum record length was 102.
      The maximum record length was 7781.
&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Oct 2017 20:02:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-File/m-p/406391#M279305</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-22T20:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-File/m-p/406446#M279306</link>
      <description>&lt;P&gt;Thanks very much for your help. This worked well for me.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Cheers&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Chris&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2017 10:00:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-File/m-p/406446#M279306</guid>
      <dc:creator>cmoore</dc:creator>
      <dc:date>2017-10-23T10:00:54Z</dc:date>
    </item>
  </channel>
</rss>

