<?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: Delimiter(Pipe) not being read if embedded in double or single quotes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726254#M225677</link>
    <description>Try remove option DSD</description>
    <pubDate>Mon, 15 Mar 2021 12:56:50 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2021-03-15T12:56:50Z</dc:date>
    <item>
      <title>Delimiter(Pipe) not being read if embedded in double or single quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726251#M225676</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need some help please!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to import a .dat file into SAS using infile.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data is pipe(|) delimited. However some of the data is like the following: a|b|c|d|"Mr John|Smith"|e|f|. As you can see the delimiter is embedded in between two data columns but in between double quotes (there are some with single quotes too). How can I get around this so that the delimiter is recognised and the data is imported correctly?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example of my data step:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data library.file;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; infile "filepath" DLM = '|' DSD MISSOVER firstobs=3;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; format&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var1 $99.&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var2 $99.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var3 $99.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var4 $99.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; firstname &amp;nbsp;$99.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; surname $99.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var5&amp;nbsp; $99.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var6&amp;nbsp; $99.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; input&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var1 $&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var2 $&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var3 $&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var4 $&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; firstname &amp;nbsp;$&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; surname $&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var5&amp;nbsp; $&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var6&amp;nbsp; $&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 12:51:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726251#M225676</guid>
      <dc:creator>Feefee</dc:creator>
      <dc:date>2021-03-15T12:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter(Pipe) not being read if embedded in double or single quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726254#M225677</link>
      <description>Try remove option DSD</description>
      <pubDate>Mon, 15 Mar 2021 12:56:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726254#M225677</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-03-15T12:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter(Pipe) not being read if embedded in double or single quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726259#M225680</link>
      <description>&lt;P&gt;The purpose of quotes in delimited files it to protect the delimiters when it appears in the the value of one of the fields.&amp;nbsp; The DSD option is that is enabling the dataset to parse the line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So in a normal interpretation of the string:&lt;/P&gt;
&lt;PRE&gt; a|b|c|d|"Mr John|Smith"|e|f|.&lt;/PRE&gt;
&lt;P&gt;There are 8 values there:&lt;/P&gt;
&lt;PRE&gt;a
b
c
d
Mr John|Smith
e
f
.&lt;/PRE&gt;
&lt;P&gt;How do you want that line to be parsed instead?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There a some combinations of strings that can confuse SAS's parsing of lines.&amp;nbsp; Since SAS supports either single or double quotes around string the normal input process does also.&amp;nbsp; &amp;nbsp;So these two lines are the same to SAS.&lt;/P&gt;
&lt;PRE&gt;a|'hi|there'|c
a|"hi|there"|c&lt;/PRE&gt;
&lt;P&gt;If you have messy data where there exists on the same line a value that starts with a single quote and another that ends in a single quote you could have problems.&amp;nbsp; Like this:&lt;/P&gt;
&lt;PRE&gt;a|b|c|d
a|'hi|c|x'&lt;/PRE&gt;
&lt;P&gt;Is that your situation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 13:04:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726259#M225680</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-15T13:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter(Pipe) not being read if embedded in double or single quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726260#M225681</link>
      <description>That just messes up the data further as there are some values missing in between the delimiter. Thank you for responding though!</description>
      <pubDate>Mon, 15 Mar 2021 13:04:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726260#M225681</guid>
      <dc:creator>Feefee</dc:creator>
      <dc:date>2021-03-15T13:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter(Pipe) not being read if embedded in double or single quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726264#M225683</link>
      <description>&lt;P&gt;Yes, you are correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like my data to be parsed like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;a&lt;BR /&gt;b&lt;BR /&gt;c&lt;BR /&gt;d&lt;BR /&gt;Mr John&lt;BR /&gt;Smith&lt;BR /&gt;e&lt;BR /&gt;f&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would ideally like that the double or single quotes don't hinder the delimiter.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you know how to go around this please?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 13:10:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726264#M225683</guid>
      <dc:creator>Feefee</dc:creator>
      <dc:date>2021-03-15T13:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter(Pipe) not being read if embedded in double or single quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726268#M225686</link>
      <description>&lt;P&gt;Remove the DSD option.&lt;/P&gt;
&lt;P&gt;But the quotes will be part of the values.&lt;/P&gt;
&lt;PRE&gt;a
b
c
d
"Mr John
Smith"
e
f&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Mar 2021 13:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726268#M225686</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-15T13:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter(Pipe) not being read if embedded in double or single quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726270#M225687</link>
      <description>&lt;P&gt;Yeah, I did try that, but some of my data is empty/missing in between delimiters so it would simply ignore it which causes further issues &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 13:15:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726270#M225687</guid>
      <dc:creator>Feefee</dc:creator>
      <dc:date>2021-03-15T13:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter(Pipe) not being read if embedded in double or single quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726271#M225688</link>
      <description>&lt;P&gt;If you want want to treat the adjacent delimiters as NOT meaning one word boundary (like spaces used to align columns) then you will need to modify the line in some way.&amp;nbsp; Either remove (or replace) the quotes&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile xx dsd dlm='|' ;
input @;
_infile_ = translate(_infile_,' ','"');
input ...;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or introduce something between the delimiters.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile xx dlm='|' ;
input @;
_infile_ = tranwrd(_infile_,'||','| |');
input ...;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 13:18:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726271#M225688</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-15T13:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter(Pipe) not being read if embedded in double or single quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726283#M225692</link>
      <description>&lt;P&gt;Is it possible to fix the problem at the source?&amp;nbsp; The values with the quotes should have been quoted.&lt;/P&gt;
&lt;PRE&gt;a|b|c|d|"""Mr John"|"Smith"""|e|f|&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Mar 2021 13:29:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delimiter-Pipe-not-being-read-if-embedded-in-double-or-single/m-p/726283#M225692</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-15T13:29:12Z</dc:date>
    </item>
  </channel>
</rss>

