<?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: SAS Import CSV file - Free text column - carriage return in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128556#M294578</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's ok for me .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it may related to your SAS Version. BTW, my SAS Version is 9.3 TS1M2.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 Oct 2013 08:07:29 GMT</pubDate>
    <dc:creator>HongqiuGu</dc:creator>
    <dc:date>2013-10-30T08:07:29Z</dc:date>
    <item>
      <title>SAS Import CSV file - Free text column - carriage return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128555#M294577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an csv file with around 5 fields, one of this field (field 3) is an free text column in the source system.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I.E., user can type an message in it, so this field has carriage return value, special char, quotes, alt+enter.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Also, length of the field 3 is variable, depends on the user message.&lt;/P&gt;&lt;P&gt;So that data of the field 3 is distributed in multiple lines per observation in few rows and in one line per observation in few rows, basically depends on the length of the text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Fields description&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Field 1 – emp id&lt;/P&gt;&lt;P&gt;Field 2&amp;nbsp; - dept id&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: red;"&gt;Field 3 –&amp;nbsp; free text, it includes comma or special character, carriage return&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Field 4&amp;nbsp; - Product code&lt;/P&gt;&lt;P&gt;Field 5&amp;nbsp; - country code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Sample data&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;001,12A, &lt;SPAN style="color: red;"&gt;Tues to Friday John rotates with Team, Perm 10800-1645 Sat&lt;BR /&gt; Perm 8am starts Tue to Sat as of 22/02&lt;/SPAN&gt;&lt;SPAN style="color: black;"&gt;, cards, UK&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;002,12B, &lt;SPAN style="color: red;"&gt;Mon to Wed Marry rotates with Team, Perm 0800-1645 Sat&lt;BR /&gt; Perm 8am starts Tue to Sat as of 22/02&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: red;"&gt;Works in shift&lt;/SPAN&gt;&lt;SPAN style="color: black;"&gt;, HL, UK&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;003,12c, &lt;SPAN style="color: red;"&gt;Sat&amp;amp;Sun&lt;/SPAN&gt;&lt;SPAN style="color: red;"&gt; Paul rotates with Team, Perm 19000-1645 Sat,HL, UK&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: red;"&gt;004,12D, All day&lt;/SPAN&gt;&lt;SPAN style="color: red;"&gt; Joe rotates with PL Team, Perm 10800-1645 Sat&lt;BR /&gt; 8am starts Tue to Sat as of 24/02&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: red;"&gt;Works in shift&lt;/SPAN&gt;&lt;SPAN style="color: black;"&gt;, CC, UK&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even I am okay if I exclude the field 3 and read the rest of the fields correctly. &lt;/P&gt;&lt;P&gt;I tried with PROC Import but not able to find an option of excluding the particular column/fields.&lt;/P&gt;&lt;P&gt;Field 3 data highlighted in red colour. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please suggest an approach to read this csv file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 06:35:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128555#M294577</guid>
      <dc:creator>angorwat</dc:creator>
      <dc:date>2013-10-30T06:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Import CSV file - Free text column - carriage return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128556#M294578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's ok for me .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it may related to your SAS Version. BTW, my SAS Version is 9.3 TS1M2.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 08:07:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128556#M294578</guid>
      <dc:creator>HongqiuGu</dc:creator>
      <dc:date>2013-10-30T08:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Import CSV file - Free text column - carriage return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128557#M294579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data output(drop=line);&lt;/P&gt;&lt;P&gt;infile 'infile.csv'&amp;nbsp; truncover;&lt;/P&gt;&lt;P&gt;input line $1000.;&lt;/P&gt;&lt;P&gt;field1=scan(line,1,',');&lt;/P&gt;&lt;P&gt;field2=scan(line,2,',');&lt;/P&gt;&lt;P&gt;field3=compress(substr(line,index(line,trim(scan(line,2,',')))+length(trim(scan(line,2,',')))+1,&lt;/P&gt;&lt;P&gt;((index(line,trim(scan(line,-2,',')))-1)-(index(line,trim(scan(line,2,',')))+length(trim(scan(line,2,',')))+1))),'"');&lt;/P&gt;&lt;P&gt;field4=scan(line,-2,',');&lt;/P&gt;&lt;P&gt;field5=scan(line,-1,',');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 09:21:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128557#M294579</guid>
      <dc:creator>pradeepalankar</dc:creator>
      <dc:date>2013-10-30T09:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Import CSV file - Free text column - carriage return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128558#M294580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I will try this code.&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;@ Hongqiugu - do u meant the carriage return value works in 9.3 or did used the sample data &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;btw - can we exclude any specific field/column from the csv file before reading into SAS.???&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 09:49:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128558#M294580</guid>
      <dc:creator>angorwat</dc:creator>
      <dc:date>2013-10-30T09:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Import CSV file - Free text column - carriage return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128559#M294581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I used the data you posted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;csv file is ";" separated file, actually it is the same as&amp;nbsp; txt file. you can choose what fields you want to read in or drop for csv files.but no options available&amp;nbsp; for excel files as far as I know.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 12:01:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128559#M294581</guid>
      <dc:creator>HongqiuGu</dc:creator>
      <dc:date>2013-10-30T12:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Import CSV file - Free text column - carriage return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128560#M294582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;CSV is comma separated file ',' not semicolon separated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 12:35:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128560#M294582</guid>
      <dc:creator>pradeepalankar</dc:creator>
      <dc:date>2013-10-30T12:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Import CSV file - Free text column - carriage return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128561#M294583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Angorwat,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As the original file can contain commas as separators and as data, then any data values containing a comma need to be distinguished by being surround by quotes, for example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But if, as you say, the data could contain any text, which could include quotes, then perhaps CSV is not the best format for this data to be in. Can it be provided to you in a different format to make things easier?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it cannot then perhaps look for patterns to distinguish the 3rd field, e.g. is it always preceded and followed by 2 fields separated only with a comma each, although I would not even consider that full proof.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 12:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128561#M294583</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2013-10-30T12:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Import CSV file - Free text column - carriage return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128562#M294584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi angorwat&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might be able to use the &lt;A href="http://support.sas.com/documentation/cdl/en/hostwin/63047/HTML/default/viewer.htm#chifoptfmain.htm"&gt;TERMSTR &lt;/A&gt;option to get what you want. If your field 3 also contains the separator character (,) then the value for field 3 is usually in quotes.&lt;/P&gt;&lt;P&gt;See also this discussion &lt;A __default_attr="36104" __jive_macro_name="thread" class="jive_macro jive_macro_thread" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following code will read a CSV file created in excel as outline by you&lt;/P&gt;&lt;DIV style="font-family: Consolas; font-size: 11pt;"&gt;&lt;SPAN style="color: #000080; background-color: #ffffff;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; test;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;infile&lt;/SPAN&gt; &lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;"c:\temp\csv_cr.csv"&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;dsd&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;dlm&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;","&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;missover&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;termstr&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=cr&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; emp_id : &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$8.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dept_id : &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$8.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; free_text : &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$1024.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Product_code : &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$8.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; country_code : &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$8.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000080; background-color: #ffffff;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 12:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128562#M294584</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2013-10-30T12:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Import CSV file - Free text column - carriage return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128563#M294585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should check how your file is storing end of line markers to see if it will be possible to distinguish the line breaks in the middle of a row of data from the end of the row.&amp;nbsp; It is easy to see this information using a SAS datastep using the LIST statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile 'myfile.csv' obs=10;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input;&lt;/P&gt;&lt;P&gt;&amp;nbsp; list;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also use RECFM=F to see all of the characters including the end of line characters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile 'myfile.csv' recfm=F lrecl=80 obs=10;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input;&lt;/P&gt;&lt;P&gt;&amp;nbsp; list;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On a Windows machine the end of line is normally created using the two character sequence CR+LF (carriage return and linefeed) which are hexadecimal codes 0D and 0A, respectively.&amp;nbsp; If the line breaks in the middle of your data are only coded as one of those (usually it will be the CR or '0D'x) then you can use the TERMSTR option on the INFILE statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you probably want something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile 'myfile.csv' dsd dlm=',' lrecl=100000 termstr=crlf truncover ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length empid $10 deptid $10 product $10 country $3 comment $500 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input empid deptid comment product country;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 14:11:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128563#M294585</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-10-30T14:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Import CSV file - Free text column - carriage return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128564#M294586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah,&amp;nbsp; thanks. You are right. I'm a little confused about the two words 'comma' and 'semicolon'.&amp;nbsp;&amp;nbsp;&amp;nbsp; I am not a native English speaker.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 14:27:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128564#M294586</guid>
      <dc:creator>HongqiuGu</dc:creator>
      <dc:date>2013-10-30T14:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Import CSV file - Free text column - carriage return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128565#M294587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just thought I'd add some thoughts to what a few posters have already touched on. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One issue I see is that your example data is not a properly formatted CSV file.&amp;nbsp; When I create CSV files, I encapsulate my free text fields with double quotations "like this".&amp;nbsp; This tells most software that everything between the quotes is part of one column, regardless of what it contains.&amp;nbsp; The only issue is when your free text field itself contains double quotes.&amp;nbsp; This will cause software to cut off your data prematurely.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One option is to change how the source data is generated.&amp;nbsp; Instead of using a comma, use a set of characters as your delimiter which are less likely to appear in your free text field, such as #*#*# .&amp;nbsp; You then split your data based on &lt;STRONG&gt;that&lt;/STRONG&gt; delimeter as opposed to splitting on a comma.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could also try an approach similar to &lt;STRONG&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" data-avatarid="-1" data-externalid="" data-presence="null" data-userid="8945" data-username="pradeepalankar" href="https://communities.sas.com/people/pradeepalankar" id="jive-89453369937190375786"&gt;pradeepalankar&lt;/A&gt; .&amp;nbsp; &lt;/STRONG&gt;I personally like this approach.&amp;nbsp; Get your first two and last two fields.&amp;nbsp; Everything else is your third field.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It sounds like you have flexibility for what your final data set will look like.&amp;nbsp; With the code already suggested, you easily aim for this data set:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Field1&amp;nbsp;&amp;nbsp;&amp;nbsp; Field2&amp;nbsp;&amp;nbsp;&amp;nbsp; Field3&amp;nbsp;&amp;nbsp;&amp;nbsp; Field4&amp;nbsp;&amp;nbsp;&amp;nbsp; Field5&lt;BR /&gt;001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cards&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UK&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 001,12A, Tues to Friday John rotates with Team, Perm 10800-1645 Sat Perm 8am starts Tue to Sat as of 22/02, cards, UK&lt;BR /&gt;002&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UK&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 002,12B, Mon to Wed Marry rotates with Team, Perm 0800-1645 Sat Perm 8am starts Tue to Sat as of 22/02 Works in shift, HL, UK&lt;BR /&gt;003&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UK&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 003,12c, Sat&amp;amp;Sun Paul rotates with Team, Perm 19000-1645 Sat,HL, UK&lt;BR /&gt;004&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UK&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 004,12D, All day Joe rotates with PL Team, Perm 10800-1645 Sat 8am starts Tue to Sat as of 24/02 Works in shift, CC, UK&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 16:12:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128565#M294587</guid>
      <dc:creator>jaredp</dc:creator>
      <dc:date>2013-10-30T16:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Import CSV file - Free text column - carriage return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128566#M294588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your example data actually closely mimic your real data (specifically, if the first two fields are never missing and are always in the form of ### and ##C), then you might be able to use that pattern to reconstruct the records into a form that the datastep can recognize.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try the following code (but change the 2nd line to reflect the location and name of your actual data):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (keep=a b c d e);&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile "c:\textin.txt" dlm="," dsd truncover end=lastrec;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat a b $3.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat c $1024.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat d $8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat e $8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length stuff holdstuff $1024;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain stuff;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input @;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if lastrec or (prxmatch('#\d{3},\d{2}[a-zA-Z]#o',_infile_) eq 1 and _n_ gt 1) then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lastrec then stuff=catt(stuff,_infile_);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; holdstuff=_infile_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call scan(stuff,-2,pos,len,",");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stuff=catt(substr(stuff,1,pos-2),'",',substr(stuff,pos));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _infile_=stuff;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input a b c d e;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _infile_=holdstuff;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stuff=catt(substr(_infile_,1,8),'"',substr(_infile_,9));&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if prxmatch('#\d{3},\d{2}[a-zA-Z]#o',_infile_) eq 1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stuff=catt(substr(_infile_,1,8),'"',substr(_infile_,9));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else stuff=catt(stuff,_infile_);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;p.s. While i'm sure that he will think the above far more complex than it has to be, thanks to &lt;A __default_attr="815014" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; for providing me with the prxmatch function specifics&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 20:23:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128566#M294588</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-10-30T20:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Import CSV file - Free text column - carriage return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128567#M294589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks all for your responses.&lt;/P&gt;&lt;P&gt;I managed to fix this problem using the code from &lt;A href="http://support.sas.com/kb/26/065.html" title="http://support.sas.com/kb/26/065.html"&gt;26065 - Remove carriage return and linefeed characters within quoted strings.&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 22:53:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128567#M294589</guid>
      <dc:creator>angorwat</dc:creator>
      <dc:date>2013-10-31T22:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Import CSV file - Free text column - carriage return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128568#M294590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad you solved your problem, but a number of us are not very happy that you wasted our time by not letting us know what your data really looked like.&amp;nbsp; Your example data didn't include ANY quoted strings.&amp;nbsp; If it had, obviously, different solutions would have been offered.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Nov 2013 01:27:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128568#M294590</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-11-01T01:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Import CSV file - Free text column - carriage return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128569#M294591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry about that, I didn't realized it&lt;/P&gt;&lt;P&gt;Will correct myself, ensure to provide sample data similar to real data next time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Nov 2013 11:52:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128569#M294591</guid>
      <dc:creator>angorwat</dc:creator>
      <dc:date>2013-11-01T11:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Import CSV file - Free text column - carriage return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128570#M294592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If that's the case then Tom's suggestion to use TERMSTR=CRLF should be the solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Nov 2013 13:03:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Import-CSV-file-Free-text-column-carriage-return/m-p/128570#M294592</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-11-01T13:03:35Z</dc:date>
    </item>
  </channel>
</rss>

