<?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: Export a SAS dataset to csv with termstr option in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Export-a-SAS-dataset-to-csv-with-termstr-option/m-p/807211#M318200</link>
    <description>&lt;P&gt;How is it not working?&amp;nbsp; What do you mean by "fixed the line breaks"?&lt;/P&gt;
&lt;P&gt;It works fine for me.&amp;nbsp; Here is code to test it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv temp termstr=crlf;

proc export data=sashelp.class(obs=1) file=csv dbms=csv replace;
  delimiter='|';
run;

data _null_;
  infile csv recfm=f lrecl=100;
  input;
  list;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see from the results the values are separated by | and the lines end with CRLF characters.&lt;/P&gt;
&lt;PRE&gt;RULE:     ----+----1----+----2----+----3----+----4----+----5----+

1   CHAR  Name|Sex|Age|Height|Weight..Alfred|M|14|69|112.5.. 50
    ZONE  46667567746674666677566667004667667473373373332300
    NUMR  E1D5C358C175C859784C759784DA1C6254CDC14C69C112E5DA
&lt;/PRE&gt;</description>
    <pubDate>Mon, 11 Apr 2022 17:34:16 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-04-11T17:34:16Z</dc:date>
    <item>
      <title>Export a SAS dataset to csv with termstr option</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-a-SAS-dataset-to-csv-with-termstr-option/m-p/807194#M318183</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to export my SAS dataset to csv. However, due to line breaks existing in some values of the SAS Dataset, my csv is messed up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I using the option termstr=CRLF in the proc export command, as it is used in the proc import one. When I import a csv to a SAS dataset, the prementioned option works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I export the SAS dataset to csv, this option does not work. Specifically, the below code is what I am trying to run:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;filename out "/path/test.csv" termstr=crlf;

proc export data=work.check
outfile=out dbms=csv replace;
delimiter="|";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Do you know why the above code does not fix the line breaks and does not specialize the end-of-line?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 16:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-a-SAS-dataset-to-csv-with-termstr-option/m-p/807194#M318183</guid>
      <dc:creator>Chrisas</dc:creator>
      <dc:date>2022-04-11T16:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Export a SAS dataset to csv with termstr option</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-a-SAS-dataset-to-csv-with-termstr-option/m-p/807211#M318200</link>
      <description>&lt;P&gt;How is it not working?&amp;nbsp; What do you mean by "fixed the line breaks"?&lt;/P&gt;
&lt;P&gt;It works fine for me.&amp;nbsp; Here is code to test it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv temp termstr=crlf;

proc export data=sashelp.class(obs=1) file=csv dbms=csv replace;
  delimiter='|';
run;

data _null_;
  infile csv recfm=f lrecl=100;
  input;
  list;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see from the results the values are separated by | and the lines end with CRLF characters.&lt;/P&gt;
&lt;PRE&gt;RULE:     ----+----1----+----2----+----3----+----4----+----5----+

1   CHAR  Name|Sex|Age|Height|Weight..Alfred|M|14|69|112.5.. 50
    ZONE  46667567746674666677566667004667667473373373332300
    NUMR  E1D5C358C175C859784C759784DA1C6254CDC14C69C112E5DA
&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Apr 2022 17:34:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-a-SAS-dataset-to-csv-with-termstr-option/m-p/807211#M318200</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-11T17:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: Export a SAS dataset to csv with termstr option</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-a-SAS-dataset-to-csv-with-termstr-option/m-p/807212#M318201</link>
      <description>&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/hostwin/chfnoptfmain.htm#:~:text=value%20is%20SERVER.-,TERMSTR%3D,-specifies%20the%20end" target="_self"&gt;TERMSTR=&lt;/A&gt;&amp;nbsp;documentation&lt;BR /&gt;&lt;BR /&gt;Can you provide a sample of the dataset you are exporting?&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_blank"&gt;Data2DataStep Maco instructions&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 17:35:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-a-SAS-dataset-to-csv-with-termstr-option/m-p/807212#M318201</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2022-04-11T17:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: Export a SAS dataset to csv with termstr option</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-a-SAS-dataset-to-csv-with-termstr-option/m-p/807230#M318213</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393904"&gt;@Chrisas&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Is your SAS running on Linux/Unix and are you using the csv created on Windows?&lt;/P&gt;
&lt;P&gt;By default on a typical Linux/Unix system LF (line feed) automatically introduces a carriage return (CR), whereas on Windows OS both CR and LF needs to be given.&lt;/P&gt;
&lt;P&gt;Do let us know your OS and the log.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 19:00:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-a-SAS-dataset-to-csv-with-termstr-option/m-p/807230#M318213</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-04-11T19:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Export a SAS dataset to csv with termstr option</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-a-SAS-dataset-to-csv-with-termstr-option/m-p/807236#M318215</link>
      <description>&lt;P&gt;Do you mean the text in the file contains end of line characters so that the resulting text file cannot be read by SAS?&lt;/P&gt;
&lt;P&gt;Try converting any CRLF characters in the data into just CR characters before writing the file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data for_export / view=for_export ;
  set check;
  array _character_ (_n_) _character_;
  do over _character_;
    _character_=tranwrd(_character_,'0D0A'x,'0D'x);
  end;
run;

filename out "/path/test.csv" termstr=crlf;
proc export data=for_export
  outfile=out dbms=csv replace
;
  delimiter="|";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Apr 2022 19:42:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-a-SAS-dataset-to-csv-with-termstr-option/m-p/807236#M318215</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-11T19:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: Export a SAS dataset to csv with termstr option</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-a-SAS-dataset-to-csv-with-termstr-option/m-p/807292#M318258</link>
      <description>&lt;P&gt;Hi Tom. Thank you very much for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead of "tranwrd", I used the "translate" command and it worked.&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;data for_export / view=for_export ;
  set check;
  array _character_ (_n_) _character_;
  do over _character_;
    _character_=translate(_character_,' ','0D0A'x);
  end;
run;

filename out "/path/test.csv" termstr=crlf;
proc export data=for_export
  outfile=out dbms=csv replace
;
  delimiter="|";
run;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2022 06:59:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-a-SAS-dataset-to-csv-with-termstr-option/m-p/807292#M318258</guid>
      <dc:creator>Chrisas</dc:creator>
      <dc:date>2022-04-12T06:59:37Z</dc:date>
    </item>
  </channel>
</rss>

