<?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: Loading CSV files with Non Quoted Strings in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Loading-CSV-files-with-Non-Quoted-Strings/m-p/161783#M31437</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Interesting..&lt;/P&gt;&lt;P&gt;I can probably come up with a business rule, my data will have 15 variables, and the 10th variable is the field that may have the additional comma.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm lost at how I would insert quotes around the 10th field in a datastep? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;KD&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Dec 2014 16:45:01 GMT</pubDate>
    <dc:creator>DangIT</dc:creator>
    <dc:date>2014-12-24T16:45:01Z</dc:date>
    <item>
      <title>Loading CSV files with Non Quoted Strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loading-CSV-files-with-Non-Quoted-Strings/m-p/161779#M31433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have received a CSV file with non quoted strings. One of the string variables in the file may contain values with a comma.&lt;/P&gt;&lt;P&gt;So when I load the data through Proc Import, those records will all be shifted to an additional variable.&lt;/P&gt;&lt;P&gt;Unfortunately the data is not aligned correctly for me to run it with fixed widths. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has anyone figured out a way to get around this? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2014 14:42:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loading-CSV-files-with-Non-Quoted-Strings/m-p/161779#M31433</guid>
      <dc:creator>DangIT</dc:creator>
      <dc:date>2014-12-24T14:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: Loading CSV files with Non Quoted Strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loading-CSV-files-with-Non-Quoted-Strings/m-p/161780#M31434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unless there is an additional rule that can help to identify those fields containing comma, I don't see there is a reliable way to import data precisely. I would go back asking your data source to modify their delivery in a way that the data can be easily interpreted, either adding quotes or using special delimiters that can't be found inside your field contents.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2014 15:51:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loading-CSV-files-with-Non-Quoted-Strings/m-p/161780#M31434</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-12-24T15:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Loading CSV files with Non Quoted Strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loading-CSV-files-with-Non-Quoted-Strings/m-p/161781#M31435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I figured that was the case. &lt;/P&gt;&lt;P&gt;Thanks for the quick reply. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2014 16:04:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loading-CSV-files-with-Non-Quoted-Strings/m-p/161781#M31435</guid>
      <dc:creator>DangIT</dc:creator>
      <dc:date>2014-12-24T16:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Loading CSV files with Non Quoted Strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loading-CSV-files-with-Non-Quoted-Strings/m-p/161782#M31436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would try to correct the input file using a Data step program before the Proc Import if it is possible to create a business rule. &lt;BR /&gt;For example: "only the third field has commas and there are ten fields in total".&lt;BR /&gt;In this case I would count the commas in each line, if more than 9 (for ten fields) then they belong to the third field so I can insert quotes arround it.&lt;/P&gt;&lt;P&gt;If you are not able to find a correction business rule, I'm afraid you would have to ask them to send you the file again created correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CTorres&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2014 16:23:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loading-CSV-files-with-Non-Quoted-Strings/m-p/161782#M31436</guid>
      <dc:creator>CTorres</dc:creator>
      <dc:date>2014-12-24T16:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: Loading CSV files with Non Quoted Strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loading-CSV-files-with-Non-Quoted-Strings/m-p/161783#M31437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Interesting..&lt;/P&gt;&lt;P&gt;I can probably come up with a business rule, my data will have 15 variables, and the 10th variable is the field that may have the additional comma.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm lost at how I would insert quotes around the 10th field in a datastep? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;KD&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2014 16:45:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loading-CSV-files-with-Non-Quoted-Strings/m-p/161783#M31437</guid>
      <dc:creator>DangIT</dc:creator>
      <dc:date>2014-12-24T16:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: Loading CSV files with Non Quoted Strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loading-CSV-files-with-Non-Quoted-Strings/m-p/161784#M31438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It depends on your data. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can import all as text and then clean up afterwards, i.e. if you have 16 variables instead of expected 15 then concatenate the 10th/11th and move everything over one field. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But for absolute accuracy get a new version. If source is Excel file, it doesn't have a default for quoted delimited which is usually the issue &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2014 17:06:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loading-CSV-files-with-Non-Quoted-Strings/m-p/161784#M31438</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-12-24T17:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Loading CSV files with Non Quoted Strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loading-CSV-files-with-Non-Quoted-Strings/m-p/161785#M31439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following program fix the incorrect input CSV file than contains 7 fields but the 3rd one includes commas:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%let invalid=3;&lt;BR /&gt;%let total=7;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt; length record $200 newrecord $200;&lt;BR /&gt; infile datalines ;&lt;BR /&gt; input;&lt;BR /&gt; record= _infile_;&lt;BR /&gt; from=findc(record,',');&lt;BR /&gt; do i=2 to &amp;amp;Invalid-1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; from=findc(record,',',from+1);&lt;BR /&gt; end;&lt;BR /&gt; to=findc(record,',','B');&lt;BR /&gt; do i=&amp;amp;invalid+1 to &amp;amp;total-1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; to=findc(substr(record,1,to-1),',','B');&lt;BR /&gt; end;&lt;BR /&gt; newrecord=cats(substr(record,1,from),'"',substr(record,from+1,to-from-1),'"',substr(record,to));&lt;BR /&gt; put newrecord;&lt;BR /&gt;datalines;&lt;BR /&gt;&lt;STRONG&gt;12,125,JOHN TAYLOR,NC,48,1,XYZ&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;22,7897,BROWN, PETER,MA,62,2,ZZY&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;333,1740,PETER WHITE,NY,77.2,1,XYZ&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;555,45,JUAN, MARIA, LUIS,XX,18,,BBB&lt;/STRONG&gt;&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOG:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;653&amp;nbsp; %let invalid=3;&lt;BR /&gt;654&amp;nbsp; %let total=7;&lt;BR /&gt;655&lt;BR /&gt;656&amp;nbsp; data _null_;&lt;BR /&gt;657&amp;nbsp;&amp;nbsp; length record $200 newrecord $200;&lt;BR /&gt;658&amp;nbsp;&amp;nbsp; infile datalines ;&lt;BR /&gt;659&amp;nbsp;&amp;nbsp; input;&lt;BR /&gt;660&amp;nbsp;&amp;nbsp; record= _infile_;&lt;BR /&gt;661&amp;nbsp;&amp;nbsp; from=findc(record,',');&lt;BR /&gt;662&amp;nbsp;&amp;nbsp; do i=2 to &amp;amp;Invalid-1;&lt;BR /&gt;663&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from=findc(record,',',from+1);&lt;BR /&gt;664&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;665&amp;nbsp;&amp;nbsp; to=findc(record,',','B');&lt;BR /&gt;666&amp;nbsp;&amp;nbsp; do i=&amp;amp;invalid+1 to &amp;amp;total-1;&lt;BR /&gt;667&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; to=findc(substr(record,1,to-1),',','B');&lt;BR /&gt;668&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;669&amp;nbsp;&amp;nbsp; newrecord=cats(substr(record,1,from),'"',substr(record,from+1,to-from-1),'"',substr(record,to));&lt;BR /&gt;670&amp;nbsp; &lt;STRONG&gt; put newrecord;&lt;/STRONG&gt;&lt;BR /&gt;671&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;12,125,"JOHN TAYLOR",NC,48,1,XYZ&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;22,7897,"BROWN, PETER",MA,62,2,ZZY&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;333,1740,"PETER WHITE",NY,77.2,1,XYZ&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;555,45,"JUAN, MARIA, LUIS",XX,18,,BBB&lt;/STRONG&gt;&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;676&amp;nbsp; ;&lt;BR /&gt;677&amp;nbsp; RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CTorres&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2014 18:22:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loading-CSV-files-with-Non-Quoted-Strings/m-p/161785#M31439</guid>
      <dc:creator>CTorres</dc:creator>
      <dc:date>2014-12-24T18:22:39Z</dc:date>
    </item>
  </channel>
</rss>

