<?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: Reading a CSV having a custom delimiter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123479#M25354</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, My concern would be that a file separated this way might contain commas in numeric or character fields.&amp;nbsp; It might be safer to keep the pipe character as in:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data x;&lt;/P&gt;&lt;P&gt;infile datalines delimiter='|' dsd;&lt;/P&gt;&lt;P&gt;input @;&lt;/P&gt;&lt;P&gt;_infile_ = tranwrd(_infile_,'||','|');&lt;/P&gt;&lt;P&gt;input (a b c) (:$);&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1||2,5||||&lt;/P&gt;&lt;P&gt;4||5||6&lt;/P&gt;&lt;P&gt;||8||||&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 May 2012 16:42:23 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2012-05-22T16:42:23Z</dc:date>
    <item>
      <title>Reading a CSV having a custom delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123473#M25348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would you know how I could read a CSV in which the delimiter as been set to a double pipe ('||') ? An empty value in this file would thus appear like 4 consecutive pipe ('||||'). We are still using the version 8 of SAS :smileylaugh:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I already know how to create such a file but not how to read it :smileyconfused:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks in advance for your help !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Florent&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 15:23:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123473#M25348</guid>
      <dc:creator>Florent</dc:creator>
      <dc:date>2012-05-22T15:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a CSV having a custom delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123474#M25349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... I think that&amp;nbsp; _INFILE_ has been around since V8, so maybe ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data x;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;infile datalines dsd;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;input @;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;_infile_ = tranwrd(_infile_,'||',',');&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;input a b c;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;1||2||||&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;4||5||6&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;||8||||&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;a&amp;nbsp;&amp;nbsp;&amp;nbsp; b&amp;nbsp;&amp;nbsp;&amp;nbsp; c&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ps ... some reading material ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More _Infile_ Magic, Peter Crawford&lt;/P&gt;&lt;P&gt;&lt;A class="active_link" href="http://www2.sas.com/proceedings/sugi28/086-28.pdf" title="http://www2.sas.com/proceedings/sugi28/086-28.pdf"&gt;http://www2.sas.com/proceedings/sugi28/086-28.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now _INFILE_ is an Automatic Variable − So What?, Howard Schreier,&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.nesug.org/proceedings/nesug01/cc/cc4018bw.pdf" title="http://www.nesug.org/proceedings/nesug01/cc/cc4018bw.pdf"&gt;http://www.nesug.org/proceedings/nesug01/cc/cc4018bw.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 15:35:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123474#M25349</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-05-22T15:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a CSV having a custom delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123475#M25350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, it makes the job ! &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 15:43:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123475#M25350</guid>
      <dc:creator>Florent</dc:creator>
      <dc:date>2012-05-22T15:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a CSV having a custom delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123476#M25351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nice solution, but I'm not sure you should use dsd here.&amp;nbsp; The way I understood the data structure, a double delimiter indicates there is a blank variable.&amp;nbsp; If that's the case, dsd should become&amp;nbsp; dlm=','&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 16:24:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123476#M25351</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-05-22T16:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a CSV having a custom delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123477#M25352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... DSD implies a few things:&amp;nbsp; a comma-delimiter; two consecutive commas indicate a missing value; considers delimiters within quotes as character data and strips quotes from quoted values&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DLM=',' only does the comma-delimter portion&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my example doesn't work with just DLM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 16:34:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123477#M25352</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-05-22T16:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a CSV having a custom delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123478#M25353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're right, I'm temporarily brain-fried.&amp;nbsp; Sorry about that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 16:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123478#M25353</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-05-22T16:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a CSV having a custom delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123479#M25354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, My concern would be that a file separated this way might contain commas in numeric or character fields.&amp;nbsp; It might be safer to keep the pipe character as in:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data x;&lt;/P&gt;&lt;P&gt;infile datalines delimiter='|' dsd;&lt;/P&gt;&lt;P&gt;input @;&lt;/P&gt;&lt;P&gt;_infile_ = tranwrd(_infile_,'||','|');&lt;/P&gt;&lt;P&gt;input (a b c) (:$);&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1||2,5||||&lt;/P&gt;&lt;P&gt;4||5||6&lt;/P&gt;&lt;P&gt;||8||||&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 16:42:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123479#M25354</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-05-22T16:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a CSV having a custom delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123480#M25355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree that changing the delimiter to comma might cause problem.&amp;nbsp; I would choose a character that is even more obscure.&amp;nbsp; Something untypeable perhaps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 17:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123480#M25355</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-05-22T17:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a CSV having a custom delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123481#M25356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The NUL character, of course! :smileylaugh:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 17:53:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-CSV-having-a-custom-delimiter/m-p/123481#M25356</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-05-22T17:53:39Z</dc:date>
    </item>
  </channel>
</rss>

