<?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: Proc import issue where the data is both comma separated &amp;amp; also the value have a tab or ente in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-import-issue-where-the-data-is-both-comma-separated-amp/m-p/833705#M329595</link>
    <description>&lt;P&gt;Not a TAB.&amp;nbsp; A TAB would not cause that problem.&amp;nbsp; Instead it looks like someone inserted end of line characters into the cell.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are extra lucky the character is a single LF or CR and the actual lines end with a CR and LF.&amp;nbsp; You can then use the TERMSTR=CRLF option on the INFILE statement (or if you want to try letting SAS GUESS how to read it using PROC IMPORT on the FILENAME statement).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv 'c:\have.csv' termstr=crlf;
PROC IMPORT 
  OUT= want replace
  DATAFILE= csv
  DBMS=csv
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you are only a little bit lucky the values with the end of line characters in them a quoted.&amp;nbsp; Then you can use something like this &lt;A href="https://github.com/sasutils/macros/blob/master/replace_crlf.sas" target="_self"&gt;%replace_crlf()&lt;/A&gt; macro to first pre-process the file and replace those embedded end of line characters with something else so SAS can parse the file into the right number of records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you are not lucky at all then open the file with an actual text editor and remove the line breaks by hand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Sep 2022 18:35:18 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-09-15T18:35:18Z</dc:date>
    <item>
      <title>Proc import issue where the data is both comma separated &amp; also the value have a tab or enter space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-import-issue-where-the-data-is-both-comma-separated-amp/m-p/833697#M329589</link>
      <description>&lt;P&gt;I have a CSV file that is being extracted using API (see table 1 below). I am importing that data into SAS so I can clean it up. As I am using proc&amp;nbsp; I realize that some cells have two values that looks like are separated by a tab (see column flat_value first=John last=Doe). So when I import the data wherever the values are separated by a tab they show up in a new line and under the incorrect column (see table 2).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table1:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;PID&lt;/TD&gt;&lt;TD&gt;field&lt;/TD&gt;&lt;TD&gt;label&lt;/TD&gt;&lt;TD&gt;flat_value&lt;/TD&gt;&lt;TD&gt;client_id&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;121697600&lt;/TD&gt;&lt;TD&gt;Hosp Type&lt;/TD&gt;&lt;TD&gt;Clubhouse&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;121697753&lt;/TD&gt;&lt;TD&gt;Reporting Period&lt;/TD&gt;&lt;TD&gt;6/1/2022&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;121698840&lt;/TD&gt;&lt;TD&gt;Confirm Hosp Type&lt;/TD&gt;&lt;TD&gt;Oneonta Teen Center&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;121718909&lt;/TD&gt;&lt;TD&gt;What is the name?&lt;/TD&gt;&lt;TD&gt;first = John&lt;BR /&gt;last = Doe&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;121718930&lt;/TD&gt;&lt;TD&gt;Email Address&lt;/TD&gt;&lt;TD&gt;&lt;A href="mailto:John.doe@aol.com" target="_blank" rel="noopener"&gt;John.doe@aol.com&lt;/A&gt;&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;127510515&lt;/TD&gt;&lt;TD&gt;Does you have bilingual staff?&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;121838918&lt;/TD&gt;&lt;TD&gt;Total Visits&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;121838577&lt;/TD&gt;&lt;TD&gt;Unique Individuals Served&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table 2:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;PID&lt;/TD&gt;&lt;TD&gt;field&lt;/TD&gt;&lt;TD&gt;label&lt;/TD&gt;&lt;TD&gt;flat_value&lt;/TD&gt;&lt;TD&gt;client_id&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;121697600&lt;/TD&gt;&lt;TD&gt;Hosp Type&lt;/TD&gt;&lt;TD&gt;Clubhouse&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;121697753&lt;/TD&gt;&lt;TD&gt;Reporting Period&lt;/TD&gt;&lt;TD&gt;6/1/2022&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;121698840&lt;/TD&gt;&lt;TD&gt;Confirm Hosp Type&lt;/TD&gt;&lt;TD&gt;Oneonta Teen Center&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;121718909&lt;/TD&gt;&lt;TD&gt;What is the name?&lt;/TD&gt;&lt;TD&gt;"first = John&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;last = Doe"&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;121718930&lt;/TD&gt;&lt;TD&gt;Email Address&lt;/TD&gt;&lt;TD&gt;&lt;A href="mailto:John.doe@aol.com" target="_blank" rel="noopener"&gt;John.doe@aol.com&lt;/A&gt;&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;127510515&lt;/TD&gt;&lt;TD&gt;Does you have bilingual staff?&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;121838918&lt;/TD&gt;&lt;TD&gt;Total Visits&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;121838577&lt;/TD&gt;&lt;TD&gt;Unique Individuals Served&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code being used.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;PROC IMPORT 
OUT= want
DATAFILE= "C:\have.csv" 
            DBMS=csv;
     GETNAMES=YES;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Suggestions on how to deal with the possible tab or space in one cell can be handled. I would want it to either (1) stay in the same cell but may have have a separator, or (2) have its own column or row if possible.&amp;nbsp;&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 17:51:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-import-issue-where-the-data-is-both-comma-separated-amp/m-p/833697#M329589</guid>
      <dc:creator>sas_student1</dc:creator>
      <dc:date>2022-09-15T17:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Proc import issue where the data is both comma separated &amp; also the value have a tab or ente</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-import-issue-where-the-data-is-both-comma-separated-amp/m-p/833705#M329595</link>
      <description>&lt;P&gt;Not a TAB.&amp;nbsp; A TAB would not cause that problem.&amp;nbsp; Instead it looks like someone inserted end of line characters into the cell.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are extra lucky the character is a single LF or CR and the actual lines end with a CR and LF.&amp;nbsp; You can then use the TERMSTR=CRLF option on the INFILE statement (or if you want to try letting SAS GUESS how to read it using PROC IMPORT on the FILENAME statement).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv 'c:\have.csv' termstr=crlf;
PROC IMPORT 
  OUT= want replace
  DATAFILE= csv
  DBMS=csv
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you are only a little bit lucky the values with the end of line characters in them a quoted.&amp;nbsp; Then you can use something like this &lt;A href="https://github.com/sasutils/macros/blob/master/replace_crlf.sas" target="_self"&gt;%replace_crlf()&lt;/A&gt; macro to first pre-process the file and replace those embedded end of line characters with something else so SAS can parse the file into the right number of records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you are not lucky at all then open the file with an actual text editor and remove the line breaks by hand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 18:35:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-import-issue-where-the-data-is-both-comma-separated-amp/m-p/833705#M329595</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-15T18:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Proc import issue where the data is both comma separated &amp; also the value have a tab or ente</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-import-issue-where-the-data-is-both-comma-separated-amp/m-p/833830#M329658</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; and me talk a lot about this question at this :&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Input-a-CSV-file-with-text-fields-that-contain-line-breaks/m-p/833326#M329416" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Input-a-CSV-file-with-text-fields-that-contain-line-breaks/m-p/833326#M329416&lt;/A&gt;</description>
      <pubDate>Fri, 16 Sep 2022 12:40:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-import-issue-where-the-data-is-both-comma-separated-amp/m-p/833830#M329658</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-09-16T12:40:18Z</dc:date>
    </item>
  </channel>
</rss>

