<?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: csv import with text qualifier in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538127#M16591</link>
    <description>&lt;P&gt;Why would you use "import" for such a simple data file?&lt;/P&gt;
&lt;P&gt;Just write the data step to read it. SAS will automatically treat blanks as missing.&amp;nbsp; Just pick reasonable values for the lengths of your variables. You can always check the data after you have read it and adjust the program and re-run it.&lt;/P&gt;
&lt;P&gt;Note that none of your variables look like numbers to me.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile datalines dsd firstobs=2 truncover;
  length KeyInd $20 Addr1 $100 city $40 ID1 ID2 $20 Name $40 Country $40 ;
  input KeyInd--Country;
datalines4;
KeyInd,Addr1,city,ID1,ID2, Name, Country
Individual,"42nd Street","New York",09000033,04531-027-0031813," ", "United States"
Individual,"9 Glen Echo Crt",Buffalo,04531-079-0035670,04531-027-0031819, "Joe Smith"," "
Individual,"9 Glen Echo Crt",Buffalo,04531-079-0035670,04531-027-0031819, "Joe Smith",Canada
;;;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To read from a file instead replace the DATALINES keyword in the INFILE statement with the reference (simplest is quoted physical name of the file) to your source file and replace the in-line data with a RUN statement.&lt;/P&gt;</description>
    <pubDate>Sun, 24 Feb 2019 20:43:54 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-02-24T20:43:54Z</dc:date>
    <item>
      <title>csv import with text qualifier</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538125#M16590</link>
      <description>&lt;P&gt;I need to import a text file in csv format with text qualifiers. I tried PROC IMPORT but it didn't recognize the comma(,) as a delimiter in the file.&lt;BR /&gt;Can anyone help me with the code for&amp;nbsp;sas&amp;nbsp;import that will take care of both the comma (as delimited) and text qualifier? Please note my data has " " where there is a missing variable. I will highly appreciate any help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is how my data looks like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;KeyInd,Addr1,city,ID1,ID2, Name, Country&lt;/STRONG&gt;&lt;BR /&gt;Individual,"42nd Street","New York",09000033,04531-027-0031813," ", "United States"&lt;BR /&gt;Individual,"9 Glen Echo Crt",Buffalo,04531-079-0035670,04531-027-0031819, "Joe Smith"," "&lt;/P&gt;
&lt;P&gt;Individual,"9 Glen Echo Crt",Buffalo,04531-079-0035670,04531-027-0031819, "Joe Smith",Canada&lt;/P&gt;</description>
      <pubDate>Sun, 24 Feb 2019 20:35:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538125#M16590</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2019-02-24T20:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: csv import with text qualifier</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538127#M16591</link>
      <description>&lt;P&gt;Why would you use "import" for such a simple data file?&lt;/P&gt;
&lt;P&gt;Just write the data step to read it. SAS will automatically treat blanks as missing.&amp;nbsp; Just pick reasonable values for the lengths of your variables. You can always check the data after you have read it and adjust the program and re-run it.&lt;/P&gt;
&lt;P&gt;Note that none of your variables look like numbers to me.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile datalines dsd firstobs=2 truncover;
  length KeyInd $20 Addr1 $100 city $40 ID1 ID2 $20 Name $40 Country $40 ;
  input KeyInd--Country;
datalines4;
KeyInd,Addr1,city,ID1,ID2, Name, Country
Individual,"42nd Street","New York",09000033,04531-027-0031813," ", "United States"
Individual,"9 Glen Echo Crt",Buffalo,04531-079-0035670,04531-027-0031819, "Joe Smith"," "
Individual,"9 Glen Echo Crt",Buffalo,04531-079-0035670,04531-027-0031819, "Joe Smith",Canada
;;;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To read from a file instead replace the DATALINES keyword in the INFILE statement with the reference (simplest is quoted physical name of the file) to your source file and replace the in-line data with a RUN statement.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Feb 2019 20:43:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538127#M16591</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-24T20:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: csv import with text qualifier</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538129#M16592</link>
      <description>&lt;P&gt;do you have the sample of the SAS code you are using?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;dlm=',';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Feb 2019 20:49:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538129#M16592</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-02-24T20:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: csv import with text qualifier</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538130#M16593</link>
      <description>&lt;P&gt;Hope you tried the below code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile='path' dbms=csv replace out=want dlm=',';&lt;BR /&gt;getnames=yes;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Feb 2019 20:50:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538130#M16593</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-02-24T20:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: csv import with text qualifier</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538132#M16594</link>
      <description>Hi Tom,&lt;BR /&gt;Thanks for your help, but I have 1000+ variables. So I really can't define them in data step, I mean it will be too much. Is there a easier way?</description>
      <pubDate>Sun, 24 Feb 2019 21:18:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538132#M16594</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2019-02-24T21:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: csv import with text qualifier</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538138#M16596</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35631"&gt;@mlogan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi Tom,&lt;BR /&gt;Thanks for your help, but I have 1000+ variables. So I really can't define them in data step, I mean it will be too much. Is there a easier way?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your original post shows just 6 (six) columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;More than 1000 columns points to a massive failure in process design, BTW.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Feb 2019 21:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538138#M16596</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-02-24T21:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: csv import with text qualifier</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538171#M16597</link>
      <description>&lt;P&gt;More than 1,000 variables?&amp;nbsp; That seems excessive.&lt;/P&gt;
&lt;P&gt;Do you have data about the variables (metadata)?&amp;nbsp;&amp;nbsp;&lt;BR /&gt;If so then use the metadata to write the program to read the text file.&lt;/P&gt;
&lt;P&gt;If not then you will not have much hope of making heads or tails of 1,000+ variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also more than 1,000 variables means that you are in danger of having more lines longer than 32K, which might cause trouble for PROC IMPORT.&amp;nbsp; Especially if the header row is too long such that some of the headers are not read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 03:37:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538171#M16597</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-25T03:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: csv import with text qualifier</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538192#M16598</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 could use the import wizard (SAS EG or Studio) which will generate the data step for you.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 06:14:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/538192#M16598</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-02-25T06:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: csv import with text qualifier</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/870149#M20696</link>
      <description>&lt;P&gt;dlm=',' gives an error, use instead:&lt;/P&gt;&lt;P&gt;; delimiter = ','&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2023 12:27:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/870149#M20696</guid>
      <dc:creator>ezi</dc:creator>
      <dc:date>2023-04-17T12:27:03Z</dc:date>
    </item>
    <item>
      <title>Re: csv import with text qualifier</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/870154#M20697</link>
      <description>&lt;P&gt;With PROC IMPORT you have to use the DELIMITER= statement to change the delimiter.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you use DBMS=CSV then the delimiter will already default to a comma so you don't need the DELIMITER= statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;They were probably thinking of the DLM= option on the INFILE statement for when you write your own data step to read the text file.&amp;nbsp; But again if you use the DSD option on the INFILE statement then the default delimiter is a comma so you don't have to add the DLM= option there either.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2023 13:02:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/870154#M20697</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-17T13:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: csv import with text qualifier</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/870481#M20698</link>
      <description>When importing a CSV file that contains text fields with special characters such as commas, you can use a text qualifier to indicate that the text should be treated as a single field. Here are the steps for importing a CSV file with a text qualifier:&lt;BR /&gt;&lt;BR /&gt;Open the program you are using to import the CSV file (such as Microsoft Excel, Google Sheets, or a database program).&lt;BR /&gt;Go to the "File" menu and choose "Import" or "Open."&lt;BR /&gt;In the import wizard or dialog box, select "CSV" as the file type.&lt;BR /&gt;Choose the file you want to import and click "Next" or "Continue."&lt;BR /&gt;In the "Text Qualifier" field, enter the character that you want to use as the text qualifier. The default text qualifier is double quotes (").&lt;BR /&gt;Preview the data and make sure that the fields are being correctly separated and that the text qualifiers are being used to encapsulate text fields with special characters.&lt;BR /&gt;Complete the import process and save the data in your desired format.&lt;BR /&gt;Regards,&lt;BR /&gt;Rachel Gomez</description>
      <pubDate>Wed, 19 Apr 2023 05:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/870481#M20698</guid>
      <dc:creator>RacheLGomez123</dc:creator>
      <dc:date>2023-04-19T05:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: csv import with text qualifier</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/870490#M20703</link>
      <description>&lt;P&gt;Opening and saving a text file with something like Excel will in essence destroy it. The software will have its own ideas (like converting the &lt;U&gt;code&lt;/U&gt; 1.1 into a date) about the content.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's only one way to deal with &lt;EM&gt;undocumented&lt;/EM&gt; text files: open with a text editor, and write the code according to what you see, and what you can make of it out of your experience.&lt;/P&gt;
&lt;P&gt;If the file is documented (as it should&amp;nbsp; be), you write the code according to the doc.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 06:15:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/870490#M20703</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-04-19T06:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: csv import with text qualifier</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/878715#M20753</link>
      <description>&lt;P&gt;I used data step to import with the following option, this resolved the issue with unwanted quotes I got for the last column. Hope this helps. Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TERMSTR= option—Specifies what end-of-line character to use for a file. This option is specific to ASCII&lt;BR /&gt;operating systems and is documented in the SAS 9.2 companion for your operating system. This option is useful&lt;BR /&gt;when you want to share data files that are created on one operating system with another operating system. For&lt;BR /&gt;example, if you are working in a UNIX environment and you need to read a file that was created under Windows,&lt;BR /&gt;use TERMSTR=CRLF. Similarly, if you are in a Windows environment and you need to read a file that was&lt;BR /&gt;created under UNIX, use TERMSTR=LF.&lt;BR /&gt;The following INFILE statement illustrates reading a MAC file from a PC:&lt;BR /&gt;infile 'C:\mydata\test.dat' dsd dlm='|' termstr=cr;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 16:40:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/csv-import-with-text-qualifier/m-p/878715#M20753</guid>
      <dc:creator>arun_guru</dc:creator>
      <dc:date>2023-06-01T16:40:02Z</dc:date>
    </item>
  </channel>
</rss>

