<?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: Ignore apostrophe (single quote) in csv import in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520624#M141208</link>
    <description>&lt;P&gt;Try modifying the input line before reading it, this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TEST_QUOTE_IMPORT;
	infile "C:\TEMP\TEST_QUOTE.csv" delimiter =',' MISSOVER DSD 
        lrecl=32767 firstobs=n obs=m ;
	informat ID $13. ;
	informat ID_FLAG $1. ;
	informat ID_ALT $13. ;
	informat CHILD_BIRTH_STATE_4 $50. ;
	informat SEQUENCE $6. ;
	informat NAME_FIRST $60. ;
	informat NAME_MIDDLE_7 $60. ;
	informat NAME_LAST_8 $60. ;
        input @;
        _infile_ = prxchange("s/,('.+?),/,""\1"",/o", -1, _infile_);
        _infile_ = prxchange("s/,(.+?'),/,""\1"",/o", -1, _infile_);

		input
		ID $
		ID_FLAG $
		ID_ALT $
		SEQUENCE $
		NAME_FIRST_6 $
		NAME_MIDDLE_7 $
		NAME_LAST_8 $
		;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;where&lt;EM&gt; n&lt;/EM&gt; is a couple of lines before the problem&amp;nbsp;occurs and&lt;EM&gt; m&lt;/EM&gt; is a few lines after, for testing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Dec 2018 23:41:09 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2018-12-11T23:41:09Z</dc:date>
    <item>
      <title>Ignore apostrophe (single quote) in csv import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520593#M141191</link>
      <description>&lt;P&gt;I have a comma-delimited data file that includes names with apostrophes (i.e., single quotes).&amp;nbsp; This causes multiple fields to be read incorrectly into a single field.&amp;nbsp; For example, there have been rare instances in which the first name begins with an apostrophe and the last name ends with an apostrophe causing the first, middle, and last names to read in all together as the first name (e.g., 'LARRY,JOE,BIRD').&amp;nbsp; Is there an option that disallows single quotes to be used to enclose&amp;nbsp;text with embedded commas&amp;nbsp;but still allows double quotes to enclose text with embedded commas?&amp;nbsp; Single quotes are allowed at data entry but double quotes are not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TEST_QUOTE_IMPORT;
	infile "C:\TEMP\TEST_QUOTE.csv" delimiter =',' MISSOVER DSD lrecl=32767 firstobs=1 ;
	informat ID $13. ;
	informat ID_FLAG $1. ;
	informat ID_ALT $13. ;
	informat CHILD_BIRTH_STATE_4 $50. ;
	informat SEQUENCE $6. ;
	informat NAME_FIRST $60. ;
	informat NAME_MIDDLE_7 $60. ;
	informat NAME_LAST_8 $60. ;
		input
		ID $
		ID_FLAG $
		ID_ALT $
		SEQUENCE $
		NAME_FIRST_6 $
		NAME_MIDDLE_7 $
		NAME_LAST_8 $
		;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Dec 2018 21:46:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520593#M141191</guid>
      <dc:creator>Ryanb2</dc:creator>
      <dc:date>2018-12-11T21:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: Ignore apostrophe (single quote) in csv import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520595#M141193</link>
      <description>Are you sure you want that? Usually the quotes are used to mask an embedded comma that SHOULD NOT be read separately? If this consistent, then I would consider reading it in and then parsing it separately with the SCAN() function. Or you can pass multiple characters to the DLM option. &lt;BR /&gt;&lt;BR /&gt;DLM = "',"&lt;BR /&gt;&lt;BR /&gt;Double quotes, with a single quote and comma inside it.</description>
      <pubDate>Tue, 11 Dec 2018 21:52:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520595#M141193</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-11T21:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Ignore apostrophe (single quote) in csv import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520599#M141196</link>
      <description>&lt;P&gt;If you omit the DSD option, single and double quotes will have no special meaning. That may solve the problem you described but may also create other problems, as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;said.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 22:14:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520599#M141196</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-12-11T22:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: Ignore apostrophe (single quote) in csv import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520600#M141197</link>
      <description>&lt;P&gt;Thanks Reeza.&amp;nbsp; For this file, text with embedded commas are enclosed in double quotes, so single quotes can be ignored for this purpose.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried updating the DLM to "','" and removed the DSD option, and it solved the problem I described, but it doesn't import fields with embedded commas correctly anymore.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to write import code for a community of users so I'm trying to keep things simple.&amp;nbsp; Using the SCAN function or removing the apostrophes before import are options, but I'm hopeful another solution exists.&amp;nbsp; I tried to keep things simple in the example, but the data file includes hundreds of fields.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 22:17:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520600#M141197</guid>
      <dc:creator>Ryanb2</dc:creator>
      <dc:date>2018-12-11T22:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: Ignore apostrophe (single quote) in csv import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520602#M141199</link>
      <description>You didn't include any data. It may change things if you post a better sample or provide something that can be used to test.</description>
      <pubDate>Tue, 11 Dec 2018 22:21:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520602#M141199</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-11T22:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Ignore apostrophe (single quote) in csv import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520624#M141208</link>
      <description>&lt;P&gt;Try modifying the input line before reading it, this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TEST_QUOTE_IMPORT;
	infile "C:\TEMP\TEST_QUOTE.csv" delimiter =',' MISSOVER DSD 
        lrecl=32767 firstobs=n obs=m ;
	informat ID $13. ;
	informat ID_FLAG $1. ;
	informat ID_ALT $13. ;
	informat CHILD_BIRTH_STATE_4 $50. ;
	informat SEQUENCE $6. ;
	informat NAME_FIRST $60. ;
	informat NAME_MIDDLE_7 $60. ;
	informat NAME_LAST_8 $60. ;
        input @;
        _infile_ = prxchange("s/,('.+?),/,""\1"",/o", -1, _infile_);
        _infile_ = prxchange("s/,(.+?'),/,""\1"",/o", -1, _infile_);

		input
		ID $
		ID_FLAG $
		ID_ALT $
		SEQUENCE $
		NAME_FIRST_6 $
		NAME_MIDDLE_7 $
		NAME_LAST_8 $
		;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;where&lt;EM&gt; n&lt;/EM&gt; is a couple of lines before the problem&amp;nbsp;occurs and&lt;EM&gt; m&lt;/EM&gt; is a few lines after, for testing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 23:41:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520624#M141208</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-12-11T23:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: Ignore apostrophe (single quote) in csv import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520906#M141290</link>
      <description>&lt;P&gt;Thanks PGStats!&amp;nbsp; That fixed the issue.&amp;nbsp; Much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These kinds of instances are rare, but I find it interesting that Excel opens the file correctly by default, but SAS doesn't, and doesn't include an option that would essentially mimic the Excel process.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 16:59:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520906#M141290</guid>
      <dc:creator>Ryanb2</dc:creator>
      <dc:date>2018-12-12T16:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: Ignore apostrophe (single quote) in csv import</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520923#M141300</link>
      <description>&lt;P&gt;You are welcome. Look at it this way: SAS is much better at reading Excel data files than Excel is at reading SAS data files. &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 18:06:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ignore-apostrophe-single-quote-in-csv-import/m-p/520923#M141300</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-12-12T18:06:20Z</dc:date>
    </item>
  </channel>
</rss>

