<?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 how to remove carriage return characters from .CSV file in data step using infile in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291300#M270046</link>
    <description>&lt;P&gt;I'm importing some data from the web using an infile statement in a data step.&amp;nbsp; Some of the fields contain carriage returns / line feeds&amp;nbsp; in the middle of the data that cause bad records to be returned.&amp;nbsp; I'm trying to find the simplest was to clean up the culprit fields which have these characters so the resulting data set in my work file doesn't have these errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was thinking of using the Compress function to remove the characters, but I don't know where to put it in the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Compress(name,'0D0A'x)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a simplified version of my code that creates a work file but with errors.&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;PRE&gt;&lt;CODE class=" language-sas"&gt;filename notes url "http://www.website.com/....";

data WORK.NOTES;
  infile NOTES 
	delimiter = ',' 
	MISSOVER 
	DSD  
	firstobs=2;

	informat name $150. ;
	informat note $300. ;
	format name $150. ;
	format note $300. ;

  input

	name $
	note $;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 12 Aug 2016 15:40:22 GMT</pubDate>
    <dc:creator>popeil51</dc:creator>
    <dc:date>2016-08-12T15:40:22Z</dc:date>
    <item>
      <title>how to remove carriage return characters from .CSV file in data step using infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291300#M270046</link>
      <description>&lt;P&gt;I'm importing some data from the web using an infile statement in a data step.&amp;nbsp; Some of the fields contain carriage returns / line feeds&amp;nbsp; in the middle of the data that cause bad records to be returned.&amp;nbsp; I'm trying to find the simplest was to clean up the culprit fields which have these characters so the resulting data set in my work file doesn't have these errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was thinking of using the Compress function to remove the characters, but I don't know where to put it in the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Compress(name,'0D0A'x)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a simplified version of my code that creates a work file but with errors.&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;PRE&gt;&lt;CODE class=" language-sas"&gt;filename notes url "http://www.website.com/....";

data WORK.NOTES;
  infile NOTES 
	delimiter = ',' 
	MISSOVER 
	DSD  
	firstobs=2;

	informat name $150. ;
	informat note $300. ;
	format name $150. ;
	format note $300. ;

  input

	name $
	note $;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Aug 2016 15:40:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291300#M270046</guid>
      <dc:creator>popeil51</dc:creator>
      <dc:date>2016-08-12T15:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove carriage return characters from .CSV file in data step using infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291313#M270047</link>
      <description>&lt;P&gt;Not tested, you may need to tweak,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename notes url "http://www.website.com/....";

data WORK.NOTES;
  infile NOTES 
	delimiter = ',' 
	MISSOVER 
	DSD  
	firstobs=2
    lrecl=1000;

	informat name $150. ;
	informat note $300. ;
	format name $150. ;
	format note $300. ;
input @1 @;
_infile_=compress(_infile_,'0D0A'x);
  input

	name $
	note $;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Aug 2016 19:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291313#M270047</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-08-12T19:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove carriage return characters from .CSV file in data step using infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291315#M270048</link>
      <description>&lt;P&gt;Do you know if the issue is ONLY linefeed or is it Carriage Return Linefeed pair, or carriage return only?&lt;/P&gt;
&lt;P&gt;What OS are you running on?&lt;/P&gt;
&lt;P&gt;You may be able to set the TERMSTR= option on the infile to correct this but settings would depend on your OS and the actual content of the file.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 16:21:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291315#M270048</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-08-12T16:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove carriage return characters from .CSV file in data step using infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291358#M270049</link>
      <description>&lt;P&gt;I got this error when inserting this code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: The INFILE statement MISSOVER option and the INPUT statement double trailing @ option,
       are being used in an inconsistent manner.  The execution of the DATA STEP is being
       terminated to prevent an infinite loop condition.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Aug 2016 17:29:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291358#M270049</guid>
      <dc:creator>popeil51</dc:creator>
      <dc:date>2016-08-12T17:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove carriage return characters from .CSV file in data step using infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291359#M270050</link>
      <description>&lt;P&gt;I think the issue is carriage return only.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using SAS 9.4 on Windows server 2012.&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>Fri, 12 Aug 2016 17:32:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291359#M270050</guid>
      <dc:creator>popeil51</dc:creator>
      <dc:date>2016-08-12T17:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove carriage return characters from .CSV file in data step using infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291365#M270051</link>
      <description>&lt;P&gt;You might try TERMSTR=CRLF on the infile. This would set the requirement for both a carriage return and linefeed to appear to end a line. Note that if this works you will still have CR in the variable. That should be removed with a string function such as Translate though you'll likely need to use the Hex coded value in code.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 18:03:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291365#M270051</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-08-12T18:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove carriage return characters from .CSV file in data step using infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291375#M270052</link>
      <description>&lt;P&gt;I tried TERMSTR=CRLF and TERMSTR=CR, both produced zero records&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TERMSTR=LF produced results, but with the bad records due to carriage returns&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 18:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291375#M270052</guid>
      <dc:creator>popeil51</dc:creator>
      <dc:date>2016-08-12T18:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove carriage return characters from .CSV file in data step using infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291425#M270053</link>
      <description>&lt;P&gt;Right, changing the double @@ to single @ should fix it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input @1 @;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Previous post has been updated to reflect the change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 19:44:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291425#M270053</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-08-12T19:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove carriage return characters from .CSV file in data step using infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291426#M270054</link>
      <description>&lt;P&gt;This allowed the code to run, but the problem persists.&amp;nbsp; I will try to provide some sample data&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 19:47:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291426#M270054</guid>
      <dc:creator>popeil51</dc:creator>
      <dc:date>2016-08-12T19:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove carriage return characters from .CSV file in data step using infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291433#M270055</link>
      <description>&lt;P&gt;Seems to me you have more/different issues than you have presented. So far, we have followed the path you set, while did not get to know exactly what you mean by 'error' or 'problem'.&amp;nbsp; current process should take care of the 2 control characters you think you have, if not, you can try a full-blown version of it: COMPRESS(_INFILE_,,'C'). This will take out all of the control characters, but still may not tackle your 'error' or 'problem'.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 20:45:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291433#M270055</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-08-12T20:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove carriage return characters from .CSV file in data step using infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291449#M270056</link>
      <description>&lt;P&gt;The FILENAME statement supports the TERMSTR= option for the URL method. It can't hurt to try it there. LF is the default.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 22:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291449#M270056</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-08-12T22:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove carriage return characters from .CSV file in data step using infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291478#M270057</link>
      <description>&lt;PRE&gt;
Make it as a Stream File :


filename notes url "http://www.website.com/....";

data WORK.NOTES;
  infile NOTES recfm=n dlm='&amp;lt;' dsd;
 input @'&amp;gt;' x : $2000. @@;
run;


After that you can remove it by compress(x,'0D0A'x);

&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Aug 2016 04:42:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291478#M270057</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-08-13T04:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove carriage return characters from .CSV file in data step using infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291939#M270058</link>
      <description>&lt;P&gt;Here's some sample data and simplified code that illustrates my issue.&amp;nbsp; The imported 'notes' work file has 7 records instead of 5 due to the multiple lines in the 'notes' field for records 3 and 5 in the .txt file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename notes 'C:\NotesTest.txt';

proc import 
	datafile=notes
    out=notes
    dbms=tab replace;
	getnames = yes;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 16:20:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/291939#M270058</guid>
      <dc:creator>popeil51</dc:creator>
      <dc:date>2016-08-16T16:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove carriage return characters from .CSV file in data step using infile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/292250#M270059</link>
      <description>&lt;P&gt;Found the answer here, much thanks to Tom!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/83081#M28305" target="_blank"&gt;remove carriage returns&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 18:13:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-carriage-return-characters-from-CSV-file-in-data/m-p/292250#M270059</guid>
      <dc:creator>popeil51</dc:creator>
      <dc:date>2016-08-17T18:13:01Z</dc:date>
    </item>
  </channel>
</rss>

