<?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 Data got truncated when export to a new text file. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-got-truncated-when-export-to-a-new-text-file/m-p/895499#M353816</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a data file. "data.ods". But this file contain some pattern that I need to replace. (Replace the pattern "|^'|" to&amp;nbsp;"|^-|"). So I implemented a data step to do that and It worked as expected. After this conversion I need to save the results as a new file (data1.txt).&amp;nbsp; &amp;nbsp;However the data in data1.txt seems got truncated after some number of characters in each row.&lt;/P&gt;&lt;P&gt;(data in&amp;nbsp;data.ods has the delimiter |^)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As an example: let say that&amp;nbsp;data.ods looks like this&amp;nbsp; (using toy data)&lt;/P&gt;&lt;PRE&gt;abs|^ssass|^uuwawaaa|^hdadaaaaaaaaaaaaaaaaaaaaaaaaaaa|^sasasssas
122|^sasa|^'|^sassasasaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaassasasas|^dasas
432|^ssadasa|^sassa|^sassasasaaaaaaaaaaaaaaaaaaaaaaaaaaaahsasaassdada|^ffwa
3122|^sasdada|^'|^sassasasaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadadada|^fdaaas

&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then&amp;nbsp;data1.txt looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;abs|^ssass|^uuwawaaa|^hdadaaaaaaaaaaaaaaaaaaaaaaaaaaa|^sa
122|^sasa|^-|^sassasasaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
432|^ssadasa|^sassa|^sassasasaaaaaaaaaaaaaaaaaaaaaaaaaaaa
3122|^sasdada|^-|^sassasasaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code: Could anyone help me to resolve this issue?&amp;nbsp; Thank you very much&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;filename ipt_file "data.ods";
%let out_file=data1.txt;
data _null_;
  infile ipt_file truncover;
  file "&amp;amp;out_file" ; 
  input;
  modified_line = tranwrd(_infile_, "|^'|", "|^-|");

  /* Output the modified_line with a new line character */
  put modified_line;
  datalines;
run;&lt;BR /&gt;&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Sep 2023 19:33:18 GMT</pubDate>
    <dc:creator>sam88r</dc:creator>
    <dc:date>2023-09-22T19:33:18Z</dc:date>
    <item>
      <title>Data got truncated when export to a new text file.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-got-truncated-when-export-to-a-new-text-file/m-p/895499#M353816</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a data file. "data.ods". But this file contain some pattern that I need to replace. (Replace the pattern "|^'|" to&amp;nbsp;"|^-|"). So I implemented a data step to do that and It worked as expected. After this conversion I need to save the results as a new file (data1.txt).&amp;nbsp; &amp;nbsp;However the data in data1.txt seems got truncated after some number of characters in each row.&lt;/P&gt;&lt;P&gt;(data in&amp;nbsp;data.ods has the delimiter |^)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As an example: let say that&amp;nbsp;data.ods looks like this&amp;nbsp; (using toy data)&lt;/P&gt;&lt;PRE&gt;abs|^ssass|^uuwawaaa|^hdadaaaaaaaaaaaaaaaaaaaaaaaaaaa|^sasasssas
122|^sasa|^'|^sassasasaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaassasasas|^dasas
432|^ssadasa|^sassa|^sassasasaaaaaaaaaaaaaaaaaaaaaaaaaaaahsasaassdada|^ffwa
3122|^sasdada|^'|^sassasasaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadadada|^fdaaas

&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then&amp;nbsp;data1.txt looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;abs|^ssass|^uuwawaaa|^hdadaaaaaaaaaaaaaaaaaaaaaaaaaaa|^sa
122|^sasa|^-|^sassasasaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
432|^ssadasa|^sassa|^sassasasaaaaaaaaaaaaaaaaaaaaaaaaaaaa
3122|^sasdada|^-|^sassasasaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code: Could anyone help me to resolve this issue?&amp;nbsp; Thank you very much&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;filename ipt_file "data.ods";
%let out_file=data1.txt;
data _null_;
  infile ipt_file truncover;
  file "&amp;amp;out_file" ; 
  input;
  modified_line = tranwrd(_infile_, "|^'|", "|^-|");

  /* Output the modified_line with a new line character */
  put modified_line;
  datalines;
run;&lt;BR /&gt;&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 19:33:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-got-truncated-when-export-to-a-new-text-file/m-p/895499#M353816</guid>
      <dc:creator>sam88r</dc:creator>
      <dc:date>2023-09-22T19:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Data got truncated when export to a new text file.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-got-truncated-when-export-to-a-new-text-file/m-p/895502#M353817</link>
      <description>&lt;P&gt;You don't want the DATALINES statement in that last data step since you want to read from the INFILE statement instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You did not define a length for the variable you created, so SAS will default it to $200 since you are assigning it the result of a character function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also since you did not use a FORMAT when writing the line any leading spaces will be removed.&amp;nbsp; Which is probably fine since it looks like your lines are delimited, so leading spaces would normally be ignored anyway.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you are not changing the length of the string (you are replacing 4 characters with 4 other characters) just use the _INFILE_ variable as the target.&amp;nbsp; Note that using _INFILE_ will limit the line length to 32K bytes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile ipt_file ;
  file "&amp;amp;out_file" ; 
  input;
  _infile_= tranwrd(_infile_, "|^'|", "|^-|");
  put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 19:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-got-truncated-when-export-to-a-new-text-file/m-p/895502#M353817</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-09-22T19:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Data got truncated when export to a new text file.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-got-truncated-when-export-to-a-new-text-file/m-p/895506#M353819</link>
      <description>Thank you very much. This worked for me. Appreciate your help</description>
      <pubDate>Fri, 22 Sep 2023 20:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-got-truncated-when-export-to-a-new-text-file/m-p/895506#M353819</guid>
      <dc:creator>sam88r</dc:creator>
      <dc:date>2023-09-22T20:27:25Z</dc:date>
    </item>
  </channel>
</rss>

