<?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: Carriage Returns - Need to be removed in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586256#M167341</link>
    <description>To your question "why do you want to combine two rows into one?" because it is a pipe-delimited file and yes - there is a comment field whose values can contain carriage returns... It's how the data is being offered for me to pick up. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Also, I can reference the sftpdir() instead of having to copy over the file! Thank you for helping me solve this!</description>
    <pubDate>Wed, 04 Sep 2019 20:32:24 GMT</pubDate>
    <dc:creator>TonyVanHorn</dc:creator>
    <dc:date>2019-09-04T20:32:24Z</dc:date>
    <item>
      <title>Carriage Returns - Need to be removed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586188#M167312</link>
      <description>&lt;P&gt;How does one leverage the goodness of the TERMSTR=CRLF option in the context of reading in a .csv file that resides on an SFTP server?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when I run the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data DATA_IN;&lt;BR /&gt;infile sftpdir(myfile.csv)&lt;BR /&gt;termstr=crlf&lt;BR /&gt;truncover;&lt;BR /&gt;input row $32767.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it results in the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;27 termstr=crlf&lt;BR /&gt;_______&lt;BR /&gt;23&lt;BR /&gt;ERROR 23-2: Invalid option name TERMSTR.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 16:38:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586188#M167312</guid>
      <dc:creator>TonyVanHorn</dc:creator>
      <dc:date>2019-09-04T16:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: Carriage Returns - Need to be removed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586192#M167313</link>
      <description>&lt;P&gt;Does code that work when the libref SFTPDIR is just pointing to a regular directory on your SAS server?&lt;/P&gt;
&lt;P&gt;What version of SAS are your running?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 16:46:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586192#M167313</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-09-04T16:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: Carriage Returns - Need to be removed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586194#M167314</link>
      <description>&lt;P&gt;Yes - I can point to a non-SFTP directory and process the file in the desired manner.&amp;nbsp; I am on SAS 9.4.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 16:47:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586194#M167314</guid>
      <dc:creator>TonyVanHorn</dc:creator>
      <dc:date>2019-09-04T16:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: Carriage Returns - Need to be removed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586208#M167318</link>
      <description>&lt;P&gt;Does the DATA step to read in the CSV file work without the TERMSTR option? I want to make sure that the file is at least being read in correctly since I don't have much experience with using the&amp;nbsp;SFTP Access Method. The file should at least be read in, even thought it'll be a mess. If it doesn't work i'd take a look at the documentation to use the SFTP Access Method:&amp;nbsp;&lt;A href="https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsglobal&amp;amp;docsetTarget=p0xln1fiwsr340n1xxf4mkmfxp6f.htm&amp;amp;locale=en"&gt;https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsglobal&amp;amp;docsetTarget=p0xln1fiwsr340n1xxf4mkmfxp6f.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at the documentation here for TERMSTR option it mentions the different types. Not sure if that's an issue:&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/hostwin/69955/HTML/default/viewer.htm#chifoptfmain.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/hostwin/69955/HTML/default/viewer.htm#chifoptfmain.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, i'd try and download the file and open it in a text editor like Notepad ++. That's a nice way to see what the returns look like. I made a test file called &lt;STRONG&gt;test.csv&lt;/STRONG&gt; and attached the CSV file. Here is the CSV file in notepad++. It allows me to see the returns:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Notepad image.jpg" style="width: 302px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/32207i23BB48FA91F24245/image-size/large?v=v2&amp;amp;px=999" role="button" title="Notepad image.jpg" alt="Notepad image.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used the TERMSTR option and it read it in correctly. See sample code below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;********************************;
* READING EACH COLUMN WITH DSD *;
********************************;
/*Without termstr=crlf*/
data test1;	
	infile "S:\test.csv" dsd firstobs=2 missover;
	input Var1:8. Var2:$8.;
run;

/*With termstr=crlf*/
data test2;	
	infile "S:\test.csv" dsd firstobs=2 termstr=crlf missover;
	input Var1:8. Var2:$8.;
run;

**************************************;
* READING EVERYTHING INTO ONE COLUMN *;
**************************************;
/*Without termstr=crlf*/
data test3;	
	infile "S:\test.csv" firstobs=2 truncover;
	input row $300.;
run;

/*With termstr=crlf*/
data test4;	
	infile "S:\test.csv" firstobs=2 termstr=crlf truncover;
	input row $300.;
	var1=scan(row,1);
	var2=scan(row,2);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here are some other posts that might help:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/Carriage-Returns-Need-to-be-removed/td-p/83079" target="_blank"&gt;https://communities.sas.com/t5/General-SAS-Programming/Carriage-Returns-Need-to-be-removed/td-p/83079&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Dealing-with-carriage-returns-in-a-SAS-string/td-p/96656" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/Dealing-with-carriage-returns-in-a-SAS-string/td-p/96656&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Read-CSV-file-with-embedded-CRLF/td-p/183296" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Read-CSV-file-with-embedded-CRLF/td-p/183296&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Peter&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 17:42:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586208#M167318</guid>
      <dc:creator>Panagiotis</dc:creator>
      <dc:date>2019-09-04T17:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Carriage Returns - Need to be removed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586210#M167319</link>
      <description>&lt;P&gt;Also if you could post a few lines of fake sample data in the format you have, that would allow us to test some code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Peter&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 17:44:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586210#M167319</guid>
      <dc:creator>Panagiotis</dc:creator>
      <dc:date>2019-09-04T17:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Carriage Returns - Need to be removed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586211#M167320</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288284"&gt;@TonyVanHorn&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Yes - I can point to a non-SFTP directory and process the file in the desired manner.&amp;nbsp; I am on SAS 9.4.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In that case you will probably need to download the file first and then read it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename sftpdir ... ;
filename copy temp;

data _null_;
  infile sftpdir(myfile.csv) ;
  file copy ;
  input;
  put _infile_;
run;

data DATA_IN;
  infile COPY termstr=crlf truncover;
  input row $32767.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Sep 2019 17:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586211#M167320</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-09-04T17:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Carriage Returns - Need to be removed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586246#M167336</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&amp;amp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/152214"&gt;@Panagiotis&lt;/a&gt;&amp;nbsp;- It *seems* like I do need to 1st copy over the file from SFTP to a local drive in order to be able to use the TERMSTR=CRLF option... However, contrary to my earlier statement of "&lt;SPAN&gt;Yes - I can point to a non-SFTP directory and process the file in the desired manner..." I find that results actually aren't processing in the manner I'd like yet.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="csv contents.PNG" style="width: 201px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/32212iDB0364188883A3FC/image-size/large?v=v2&amp;amp;px=999" role="button" title="csv contents.PNG" alt="csv contents.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The picture above, I think, conveys the challenge.&amp;nbsp; I'd like to read the pipe delimited rows from this csv file into one column so that resulting value would look as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a|b|c: d thru g|h&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead, I am still getting:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bad output.PNG" style="width: 264px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/32214i4DE74DEE77049B3F/image-size/large?v=v2&amp;amp;px=999" role="button" title="bad output.PNG" alt="bad output.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using the following approach:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile "C:\csv containing variable with carriage returns.csv" 
firstobs=2
termstr=crlf 
truncover;
input row $32767.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 19:56:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586246#M167336</guid>
      <dc:creator>TonyVanHorn</dc:creator>
      <dc:date>2019-09-04T19:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Carriage Returns - Need to be removed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586252#M167339</link>
      <description>&lt;P&gt;Why do you want to combine two rows into one?&lt;/P&gt;
&lt;P&gt;Is the problem that someone has made a file that cannot be parsed by including &amp;lt;CR&amp;gt;&amp;lt;LF&amp;gt; in the middle of value of one of the fields?&lt;/P&gt;
&lt;P&gt;They didn't even include any quotes around the value like Excel would have done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming you don't have any | characters in the data just count the number of |'s you have read.&amp;nbsp; You might want to replace those special characters with something else that will be easier to deal with.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
 infile 'c:\downloads\test.csv' firstobs=2 ;
 length line $32767 ;
 do until(n_pipe&amp;gt;=3);
   input;
   line=catx('&amp;lt;cr&amp;gt;',line,_infile_);
   n_pipe=sum(n_pipe,countc(_infile_,'|'));
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs            line            n_pipe

 1     a|b|c:&amp;lt;cr&amp;gt;d thru g|h       3
&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Sep 2019 20:09:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586252#M167339</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-09-04T20:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: Carriage Returns - Need to be removed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586256#M167341</link>
      <description>To your question "why do you want to combine two rows into one?" because it is a pipe-delimited file and yes - there is a comment field whose values can contain carriage returns... It's how the data is being offered for me to pick up. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Also, I can reference the sftpdir() instead of having to copy over the file! Thank you for helping me solve this!</description>
      <pubDate>Wed, 04 Sep 2019 20:32:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Carriage-Returns-Need-to-be-removed/m-p/586256#M167341</guid>
      <dc:creator>TonyVanHorn</dc:creator>
      <dc:date>2019-09-04T20:32:24Z</dc:date>
    </item>
  </channel>
</rss>

