<?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: create 2 text files, append them and then sort them in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-2-text-files-append-them-and-then-sort-them/m-p/276941#M55539</link>
    <description>&lt;P&gt;After looking at this closer, I don't think it works. Here is the output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 19800&lt;BR /&gt;1 19809&lt;BR /&gt;1 19806&lt;BR /&gt;1 J5563 2 4&lt;BR /&gt;1 J5563 3 1&lt;BR /&gt;2 19801&lt;BR /&gt;2 J3363 4 2&lt;BR /&gt;2 J4789 2 6&lt;BR /&gt;3 19806&lt;BR /&gt;3 19807&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It combines the start_date and proc_code columns into one column and they should be two separate columns.&lt;BR /&gt;3 J8434 2 2&lt;BR /&gt;3 J4444 5 5&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jun 2016 14:20:10 GMT</pubDate>
    <dc:creator>DanD999</dc:creator>
    <dc:date>2016-06-13T14:20:10Z</dc:date>
    <item>
      <title>create 2 text files, append them and then sort them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-2-text-files-append-them-and-then-sort-them/m-p/276617#M55442</link>
      <description>&lt;P&gt;Each file would have a different number of columns. We would want to sort by the id column. Is this possible in 9.4?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data file1;
input @1 id 1. @3 start_date mmddyy10.;
format adm_date mmddyy10.;
cards;
1 03/18/2014 
1 03/27/2014
1 03/24/2014
2 03/19/2014
3 03/24/2014
3 03/25/2014

;
run;


data file2;
input @1 id 1. @3 proc_code $5. @9 app_units 1. @11 request_units 1.;
/*format start_date end_date mmddyy10.;*/
cards;
1 J5563 2 4
1 J5563 3 1
2 J3363 4 2
2 J4789 2 6
3 J8434 2 2 
3 J4444 5 5 
;
run;

1 03/18/2014 
1 03/27/2014
1 03/24/2014
1 J5563 2 4
1 J5563 3 1
2 03/19/2014
2 J3363 4 2
2 J4789 2 6
3 03/24/2014
3 03/25/2014
3 J8434 2 2
3 J4444 5 5








&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jun 2016 21:17:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-2-text-files-append-them-and-then-sort-them/m-p/276617#M55442</guid>
      <dc:creator>DanD999</dc:creator>
      <dc:date>2016-06-10T21:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: create 2 text files, append them and then sort them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-2-text-files-append-them-and-then-sort-them/m-p/276619#M55444</link>
      <description>&lt;P&gt;Your example output tends to imply that you have combined the two datasets and are exporting to one file, not two.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This creates a data set with contents that look like your output. I have removed the blank line generated in your data step for file1.&lt;/P&gt;
&lt;P&gt;The OPTIONS MISSING=' '; is so that the bit that combines all of the variables in the temporary set don't get . The catx places a single space between all of the non-missing values that way. If your real data has more variables you may need to increase the length of the Line variable to accomodate more or longer variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data file1;
input @1 id 1. @3 start_date mmddyy10.;
format adm_date mmddyy10.;
cards;
1 03/18/2014 
1 03/27/2014
1 03/24/2014
2 03/19/2014
3 03/24/2014
3 03/25/2014
;
run;


data file2;
input @1 id 1. @3 proc_code $5. @9 app_units 1. @11 request_units 1.;
/*format start_date end_date mmddyy10.;*/
cards;
1 J5563 2 4
1 J5563 3 1
2 J3363 4 2
2 J4789 2 6
3 J8434 2 2 
3 J4444 5 5 
;
run;

options missing=' ';
data temp;
   set file1 file2;
   length line $ 200;
   line= catx(' ',of _all_);
run;
proc sort data=temp out=want (keep=line);
   by id;
run;

proc export data=want out='path/file.txt';
run;

options missing='.';


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jun 2016 21:37:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-2-text-files-append-them-and-then-sort-them/m-p/276619#M55444</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-06-10T21:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: create 2 text files, append them and then sort them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-2-text-files-append-them-and-then-sort-them/m-p/276937#M55538</link>
      <description>&lt;P&gt;Thanks so much for the reply. It looks like a winner.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 13:55:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-2-text-files-append-them-and-then-sort-them/m-p/276937#M55538</guid>
      <dc:creator>DanD999</dc:creator>
      <dc:date>2016-06-13T13:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: create 2 text files, append them and then sort them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-2-text-files-append-them-and-then-sort-them/m-p/276941#M55539</link>
      <description>&lt;P&gt;After looking at this closer, I don't think it works. Here is the output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 19800&lt;BR /&gt;1 19809&lt;BR /&gt;1 19806&lt;BR /&gt;1 J5563 2 4&lt;BR /&gt;1 J5563 3 1&lt;BR /&gt;2 19801&lt;BR /&gt;2 J3363 4 2&lt;BR /&gt;2 J4789 2 6&lt;BR /&gt;3 19806&lt;BR /&gt;3 19807&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It combines the start_date and proc_code columns into one column and they should be two separate columns.&lt;BR /&gt;3 J8434 2 2&lt;BR /&gt;3 J4444 5 5&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 14:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-2-text-files-append-them-and-then-sort-them/m-p/276941#M55539</guid>
      <dc:creator>DanD999</dc:creator>
      <dc:date>2016-06-13T14:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: create 2 text files, append them and then sort them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-2-text-files-append-them-and-then-sort-them/m-p/276946#M55541</link>
      <description>&lt;P&gt;I took out the &lt;SPAN class="token procnames"&gt;options&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;missing&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;; line and it looks like that may work. It preserves each column. I'll have to look at the actual data but I think this might work. Thanks for the help.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 14:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-2-text-files-append-them-and-then-sort-them/m-p/276946#M55541</guid>
      <dc:creator>DanD999</dc:creator>
      <dc:date>2016-06-13T14:28:17Z</dc:date>
    </item>
  </channel>
</rss>

