<?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 CSV different termstr in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/CSV-different-termstr/m-p/741055#M231620</link>
    <description>&lt;P&gt;I have a load of CSV files in with the same layout with the exception of the termstr. Some have CR, the others CRLF.&lt;/P&gt;&lt;P&gt;Is there an easy way to import all of these? This is my current code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename tsvs "/Path/To/Files/*.txt";
data test;
infile tsvs filename=tsvfile dlm=',' dsd missover TERMSTR=CR; 
input code:$5. @;
if code='P10' then
	do;
		fName=scan(scan(tsvfile,-1,"/"),1,".");
		input @7 a b c$ d$ e$ f$ g;
		output test;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This only works for the CR ones. I can then have another code that has CRLF as the termstr and append them together, but is there a way to do it together? Or get SAS to clean the CSVs first?&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;</description>
    <pubDate>Thu, 13 May 2021 10:56:27 GMT</pubDate>
    <dc:creator>darrenhoggard</dc:creator>
    <dc:date>2021-05-13T10:56:27Z</dc:date>
    <item>
      <title>CSV different termstr</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-different-termstr/m-p/741055#M231620</link>
      <description>&lt;P&gt;I have a load of CSV files in with the same layout with the exception of the termstr. Some have CR, the others CRLF.&lt;/P&gt;&lt;P&gt;Is there an easy way to import all of these? This is my current code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename tsvs "/Path/To/Files/*.txt";
data test;
infile tsvs filename=tsvfile dlm=',' dsd missover TERMSTR=CR; 
input code:$5. @;
if code='P10' then
	do;
		fName=scan(scan(tsvfile,-1,"/"),1,".");
		input @7 a b c$ d$ e$ f$ g;
		output test;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This only works for the CR ones. I can then have another code that has CRLF as the termstr and append them together, but is there a way to do it together? Or get SAS to clean the CSVs first?&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;</description>
      <pubDate>Thu, 13 May 2021 10:56:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-different-termstr/m-p/741055#M231620</guid>
      <dc:creator>darrenhoggard</dc:creator>
      <dc:date>2021-05-13T10:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: CSV different termstr</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-different-termstr/m-p/741064#M231626</link>
      <description>&lt;P&gt;Run an intermediate step first:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
infile "your_filepath.txt" recfm=n;
file "your_filepath.crlf" recfm=n;
input inchar $char1.;
if inchar ne '0a'x
then do;
  put inchar %char1.;
  if inchar = '0d'x then put '0a'x;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So all your files have CRLF termination strings; put this into a macro and run it on all your files with CALL EXECUTE from a data step that reads the directory. Then run your import data step from the intermediate files.&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 11:42:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-different-termstr/m-p/741064#M231626</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-13T11:42:20Z</dc:date>
    </item>
  </channel>
</rss>

