<?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: Importing csv Text file with comma and double quote in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559015#M17096</link>
    <description>&lt;P&gt;You have ambiguous column names, that is not valid. Have that fixed at the data source.&lt;/P&gt;</description>
    <pubDate>Wed, 15 May 2019 15:28:14 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-05-15T15:28:14Z</dc:date>
    <item>
      <title>Importing csv Text file with comma and double quote</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559007#M17094</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I tried to import data from a csv text file and failed to import successfully. Here is my code, can someone please help me with the correct code.&lt;/P&gt;
&lt;P&gt;Sample data file is attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank You.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc import datafile="C:\2019_05_14\CanNCOA2_Results01.txt" &lt;BR /&gt;out=Address.CanNCOA_Results&lt;BR /&gt;dbms=csv;&lt;BR /&gt;delimiter = ",";&lt;BR /&gt;getnames=yes;&lt;BR /&gt;guessingrows=100000;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 15:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559007#M17094</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2019-05-15T15:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: Importing csv Text file with comma and double quote</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559013#M17095</link>
      <description>Remove the delimiter option and it should be fine. Quotes around character variables are part of the CSV standard. If that still doesn't work try changing guessingrows to MAX instead of 100000. Or write your data step code that's customized to the data.</description>
      <pubDate>Wed, 15 May 2019 15:25:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559013#M17095</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-15T15:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: Importing csv Text file with comma and double quote</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559015#M17096</link>
      <description>&lt;P&gt;You have ambiguous column names, that is not valid. Have that fixed at the data source.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 15:28:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559015#M17096</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-15T15:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: Importing csv Text file with comma and double quote</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559017#M17097</link>
      <description>&lt;P&gt;The file looks normal to me. So your&amp;nbsp;code should run.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course since you are using PROC IMPORT it will have to guess at what type of data is in each field.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could just write your own data step to read the file instead.&amp;nbsp; Then you will have total control over how the variables are defined.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 15:30:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559017#M17097</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-15T15:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: Importing csv Text file with comma and double quote</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559018#M17098</link>
      <description>Hi Reeza, It did not work. Can you please write a working code for me. Thanks.</description>
      <pubDate>Wed, 15 May 2019 15:30:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559018#M17098</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2019-05-15T15:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: Importing csv Text file with comma and double quote</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559023#M17099</link>
      <description>Please explain what 'it did not work' means. Post your code and log.</description>
      <pubDate>Wed, 15 May 2019 15:36:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559023#M17099</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-15T15:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Importing csv Text file with comma and double quote</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559063#M17101</link>
      <description>&lt;P&gt;I ran this code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import
  datafile="$HOME/sascommunity/mlogan.txt" 
  out=test
  dbms=csv
  replace
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and it worked. It was just that the columns with repeated column names were imported as var27,var28 and so on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If something "does not work", post the log (use the {i} button for this), or show how the results differ from your expectations.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 16:48:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559063#M17101</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-15T16:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Importing csv Text file with comma and double quote</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559067#M17102</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The file looks normal to me. So your&amp;nbsp;code should run.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course since you are using PROC IMPORT it will have to guess at what type of data is in each field.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could just write your own data step to read the file instead.&amp;nbsp; Then you will have total control over how the variables are defined.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Or modify the code created by Proc Import.&lt;/P&gt;
&lt;P&gt;There should be a data step in the LOG you can copy and modify after fixing the column name issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your example data is short I would suggest making the fields a bit wider, especially any that your example data set to $1 because the field was missing.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 16:57:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559067#M17102</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-15T16:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: Importing csv Text file with comma and double quote</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559204#M17119</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35631"&gt;@mlogan&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can help us help you by always providing the SAS Log part which shows the first ERROR message.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Removing the delimiter statement as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;proposes creates valid Proc Import syntax for a csv file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the ERROR you get by any chance&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ERROR: Physical file does not exist&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so then always be aware that any file you want to import via SAS code must be referenced as the machine "sees" it from where your SAS code executes. If you don't have a local SAS installation then that's SAS on your server machine and all paths must be as on your server - which is not your local C: drive.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're using SAS EG then there is an upload task to move a file from a local to a server environment and then execute Proc Import against the path on the server.&lt;/P&gt;
&lt;P&gt;Even easier with EG is to use the Import task (File/Import) as this will both upload your data to the server and generate valid SAS code to read the data in one go.&lt;/P&gt;
&lt;P&gt;I believe there are similar options available with SAS Studio.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 02:51:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Importing-csv-Text-file-with-comma-and-double-quote/m-p/559204#M17119</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-05-16T02:51:53Z</dc:date>
    </item>
  </channel>
</rss>

