<?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 How do I combine two text files data and output one text file with the same information? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-combine-two-text-files-data-and-output-one-text-file/m-p/744271#M233158</link>
    <description>&lt;P&gt;I have two text files or maybe more two but for this example, two text files. I would like the code to capture two or more text files, sort them by the numbers in the first column before the | then and combine the data in the multiple text files then output it to one text files with the same format with the first column or numbers sorted. How would I write a code to tackle this?&lt;/P&gt;</description>
    <pubDate>Thu, 27 May 2021 19:11:57 GMT</pubDate>
    <dc:creator>kmin87</dc:creator>
    <dc:date>2021-05-27T19:11:57Z</dc:date>
    <item>
      <title>How do I combine two text files data and output one text file with the same information?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-combine-two-text-files-data-and-output-one-text-file/m-p/744271#M233158</link>
      <description>&lt;P&gt;I have two text files or maybe more two but for this example, two text files. I would like the code to capture two or more text files, sort them by the numbers in the first column before the | then and combine the data in the multiple text files then output it to one text files with the same format with the first column or numbers sorted. How would I write a code to tackle this?&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 19:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-combine-two-text-files-data-and-output-one-text-file/m-p/744271#M233158</guid>
      <dc:creator>kmin87</dc:creator>
      <dc:date>2021-05-27T19:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine two text files data and output one text file with the same information?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-combine-two-text-files-data-and-output-one-text-file/m-p/744279#M233164</link>
      <description>&lt;P&gt;Are you running on Unix? Can you call operating system commands?&amp;nbsp; If so I would just use CAT to concatenate the files and SORT to sort the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are forced to use SAS code only then read the lines and sort by the first field.&amp;nbsp; From your examples the first field is text.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename in ('TEST1.txt','TEST2.txt');
data all ;
  infile in truncover dsd dlm='|';
  input id :$20. ;
  length line $4000 ;
  line=_infile_;
run;
proc sort data=all;
  by id ;
run;
data _null_;
  file 'newfile.txt' ;
  set all;
  len = lengthn(line);
  put line $varying4000. len;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Change the 4000 length for the LINE variable to whatever makes sense for your actual files.&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 19:34:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-combine-two-text-files-data-and-output-one-text-file/m-p/744279#M233164</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-27T19:34:35Z</dc:date>
    </item>
  </channel>
</rss>

