<?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 proc export into a CSV: 2 observations break into 4 lines (each observation break into 2 lines) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-export-into-a-CSV-2-observations-break-into-4-lines-each/m-p/937961#M368486</link>
    <description>&lt;P&gt;Hello SAS community,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset of N=107 and I use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc export data=Apollo_final &lt;BR /&gt;dbms=csv outfile='apollo.csv' &lt;BR /&gt;replace; &lt;BR /&gt;delimiter = "|";&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;but 2 of the observations broke from this&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rykwong_0-1722522575138.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/98956i586BD55F00CE3603/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rykwong_0-1722522575138.png" alt="rykwong_0-1722522575138.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;into this in the CSV output.&amp;nbsp; Any help?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rykwong_1-1722522651939.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/98957i289AE1F77E0DD7F8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rykwong_1-1722522651939.png" alt="rykwong_1-1722522651939.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Aug 2024 14:31:08 GMT</pubDate>
    <dc:creator>rykwong</dc:creator>
    <dc:date>2024-08-01T14:31:08Z</dc:date>
    <item>
      <title>proc export into a CSV: 2 observations break into 4 lines (each observation break into 2 lines)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-export-into-a-CSV-2-observations-break-into-4-lines-each/m-p/937961#M368486</link>
      <description>&lt;P&gt;Hello SAS community,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset of N=107 and I use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc export data=Apollo_final &lt;BR /&gt;dbms=csv outfile='apollo.csv' &lt;BR /&gt;replace; &lt;BR /&gt;delimiter = "|";&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;but 2 of the observations broke from this&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rykwong_0-1722522575138.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/98956i586BD55F00CE3603/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rykwong_0-1722522575138.png" alt="rykwong_0-1722522575138.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;into this in the CSV output.&amp;nbsp; Any help?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rykwong_1-1722522651939.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/98957i289AE1F77E0DD7F8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rykwong_1-1722522651939.png" alt="rykwong_1-1722522651939.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 14:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-export-into-a-CSV-2-observations-break-into-4-lines-each/m-p/937961#M368486</guid>
      <dc:creator>rykwong</dc:creator>
      <dc:date>2024-08-01T14:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: proc export into a CSV: 2 observations break into 4 lines (each observation break into 2 lines)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-export-into-a-CSV-2-observations-break-into-4-lines-each/m-p/937964#M368487</link>
      <description>&lt;P&gt;It is really hard to tell from PHOTOGRAPHS of text what you mean.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's assume you mean that the CSV file has more LINES than the number of OBSERVATIONS that existed in the SAS dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are two issues that will cause the generated CSV file to appear to have more lines.&amp;nbsp; Some of the text values have embedded end-of-line characters in them.&amp;nbsp; The lines being written were too long and so SAS wrapped to the next line to finish writing the observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the second problem make sure that the LRECL used when writing the text file is large enough to hold the longest possible line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the first problem you should clean the data and remove (or replace) any CR and/or LF characters in the data.&amp;nbsp; If you tell SAS to write the text file using CR+LF as the end-of-line marker then you can leave in the LF and CR characters as long are they are no CR+LF pairs.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv 'apollo.csv' lrecl=1000000 termstr=crlf;

data for_export;
  set apollo_final;
  array _char_ _character_;
  do over _char_;
     _char_ = tranwrd(_char_,'0D0A'x,'0D'x);
  end;
run;

proc export data=for_export dbms=csv outfile=csv ;
  delimiter = "|";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Aug 2024 15:03:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-export-into-a-CSV-2-observations-break-into-4-lines-each/m-p/937964#M368487</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-01T15:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: proc export into a CSV: 2 observations break into 4 lines (each observation break into 2 lines)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-export-into-a-CSV-2-observations-break-into-4-lines-each/m-p/937965#M368488</link>
      <description>Sorry for the screenshot&lt;BR /&gt;I will try your suggestion.  Many thanks&lt;BR /&gt;</description>
      <pubDate>Thu, 01 Aug 2024 15:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-export-into-a-CSV-2-observations-break-into-4-lines-each/m-p/937965#M368488</guid>
      <dc:creator>rykwong</dc:creator>
      <dc:date>2024-08-01T15:08:04Z</dc:date>
    </item>
  </channel>
</rss>

