<?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: Embedded Double Quote Delimiter Import PIPE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Embedded-Double-Quote-Delimiter-Import-PIPE/m-p/638168#M189755</link>
    <description>&lt;P&gt;I'm invoking my pipe this way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename test pipe "ls -a /mypath/myfile.csv";

Then in a data step:

INFILE test TRUNCOVER ;
INPUT name $100.;
INFILE dummy FILEVAR=name DSD dlm=',' END=last FIRSTOBS=2 LENGTH=len ;&lt;BR /&gt;&lt;BR /&gt;When&amp;nbsp;I remove&amp;nbsp;the&amp;nbsp;DSD from&amp;nbsp;the&amp;nbsp;second&amp;nbsp;infile&amp;nbsp;statement,&amp;nbsp;I get&amp;nbsp;a&amp;nbsp;bunch&amp;nbsp;of&amp;nbsp;"Invalid&amp;nbsp;data" errors&amp;nbsp;...&amp;nbsp;Is&amp;nbsp;the&amp;nbsp;only&amp;nbsp;solution&amp;nbsp;to&amp;nbsp;fix&amp;nbsp;the&amp;nbsp;input&amp;nbsp;file?&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Apr 2020 21:31:45 GMT</pubDate>
    <dc:creator>shl007</dc:creator>
    <dc:date>2020-04-07T21:31:45Z</dc:date>
    <item>
      <title>Embedded Double Quote Delimiter Import PIPE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Embedded-Double-Quote-Delimiter-Import-PIPE/m-p/638142#M189747</link>
      <description>&lt;P&gt;Hi - I have a CSV file that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Joe the "Best" Company", "45.90"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm importing this CSV via a PIPE command and a data step. What's happening is, the name in the first column is getting split due to the embedded double quote delimiter. Is there any way around this? I've included the DSD setting in my import data step using a pipe.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any tips.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 17:33:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Embedded-Double-Quote-Delimiter-Import-PIPE/m-p/638142#M189747</guid>
      <dc:creator>shl007</dc:creator>
      <dc:date>2020-04-07T17:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: Embedded Double Quote Delimiter Import PIPE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Embedded-Double-Quote-Delimiter-Import-PIPE/m-p/638144#M189748</link>
      <description>&lt;P&gt;What does the rest of the file look like? If you cannot have an embedded comma for example you can try removing the DSD option and just assume it's comma delimited. You'll need to expand a bit on your issue. If you could include a few lines and the code you're currently using that would be helpful.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 17:36:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Embedded-Double-Quote-Delimiter-Import-PIPE/m-p/638144#M189748</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-04-07T17:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Embedded Double Quote Delimiter Import PIPE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Embedded-Double-Quote-Delimiter-Import-PIPE/m-p/638145#M189749</link>
      <description>&lt;P&gt;Who generated that file?&amp;nbsp; They should be instructed to generate files that can be parsed.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 17:50:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Embedded-Double-Quote-Delimiter-Import-PIPE/m-p/638145#M189749</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-07T17:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: Embedded Double Quote Delimiter Import PIPE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Embedded-Double-Quote-Delimiter-Import-PIPE/m-p/638168#M189755</link>
      <description>&lt;P&gt;I'm invoking my pipe this way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename test pipe "ls -a /mypath/myfile.csv";

Then in a data step:

INFILE test TRUNCOVER ;
INPUT name $100.;
INFILE dummy FILEVAR=name DSD dlm=',' END=last FIRSTOBS=2 LENGTH=len ;&lt;BR /&gt;&lt;BR /&gt;When&amp;nbsp;I remove&amp;nbsp;the&amp;nbsp;DSD from&amp;nbsp;the&amp;nbsp;second&amp;nbsp;infile&amp;nbsp;statement,&amp;nbsp;I get&amp;nbsp;a&amp;nbsp;bunch&amp;nbsp;of&amp;nbsp;"Invalid&amp;nbsp;data" errors&amp;nbsp;...&amp;nbsp;Is&amp;nbsp;the&amp;nbsp;only&amp;nbsp;solution&amp;nbsp;to&amp;nbsp;fix&amp;nbsp;the&amp;nbsp;input&amp;nbsp;file?&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 21:31:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Embedded-Double-Quote-Delimiter-Import-PIPE/m-p/638168#M189755</guid>
      <dc:creator>shl007</dc:creator>
      <dc:date>2020-04-07T21:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: Embedded Double Quote Delimiter Import PIPE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Embedded-Double-Quote-Delimiter-Import-PIPE/m-p/638174#M189757</link>
      <description>&lt;P&gt;Your description seems strange. You started off saying you had a file you were reading with PIPE that had this content.&lt;/P&gt;
&lt;PRE&gt;"Joe the "Best" Company", "45.90"&lt;/PRE&gt;
&lt;P&gt;Then you show a fileref using a PIPE that is NOT generating anything at all like that content.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename test pipe "ls -a /mypath/myfile.csv";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That LS command will generate at the most one line of text. Which is just the text your already gave it.&amp;nbsp; Not sure why it is part of the discussion.&lt;/P&gt;
&lt;P&gt;Are you saying the myfile.csv is the file that has the improperly quoted values?&lt;/P&gt;
&lt;P&gt;Who generated that file? What software did they use?&lt;/P&gt;
&lt;P&gt;It shouldn't really matter how complex your INFILE statement is, the question is how is the INPUT statement working that is trying to read that misquoted line?&amp;nbsp; As long as your values don't also have embedded commas (like the embedded quotes that are causing you trouble) then you should be able to read the line without the DSD option. But the quotes will cause issues.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  infile cards dlm=',' truncover ;
  length var1 $100 var2 $20 ;
  input var1 var2 ;
  put (var1 var2) (=);
  if var1=:'"' then var1=substrn(var1,2,length(var1)-2);
  if var2=:'"' then var2=substrn(var2,2,length(var2)-2);
  put (var1 var2) (=);
cards;
"Joe the "Best" Company", "45.90"
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;var1="Joe the "Best" Company" var2="45.90"
var1=Joe the "Best" Company var2=45.90
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 21:56:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Embedded-Double-Quote-Delimiter-Import-PIPE/m-p/638174#M189757</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-07T21:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Embedded Double Quote Delimiter Import PIPE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Embedded-Double-Quote-Delimiter-Import-PIPE/m-p/638203#M189775</link>
      <description>&lt;P&gt;Supposing the data is as described, and not coming from ls, this is slightly simpler:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  infile "&amp;amp;filename" dlm=',' truncover pad ;
  length VAR1 $100 VAR2 $20 ;
  input VAR1 VAR2 ;
  VAR1 = dequote (VAR1);
  VAR2 = dequote (VAR2);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2020 00:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Embedded-Double-Quote-Delimiter-Import-PIPE/m-p/638203#M189775</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-04-08T00:13:08Z</dc:date>
    </item>
  </channel>
</rss>

