<?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 Merge/Concat in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Merge-Concat/m-p/47115#M12617</link>
    <description>Hi,.&lt;BR /&gt;
&lt;BR /&gt;
I use the code to merge the two files , the code is -&lt;BR /&gt;
&lt;BR /&gt;
Data One;&lt;BR /&gt;
    INFILE "C:\sas\data_A.dat";&lt;BR /&gt;
    INPUT 	        Time         		 $1-8&lt;BR /&gt;
			Date                          $9-18&lt;BR /&gt;
			Model        		 $19-24&lt;BR /&gt;
			Unit   			  25-27&lt;BR /&gt;
			INT				  28;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc print data = Data One;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Data Two;&lt;BR /&gt;
	INFILE "C:\sas\data_B.dat";&lt;BR /&gt;
	INPUT 	Time 		 $1-8&lt;BR /&gt;
			Note         $9-16;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
PROC PRINT DATA = Two;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
/*Concatenate data One and Two*/&lt;BR /&gt;
data CONCAT;&lt;BR /&gt;
	SET One and Two;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
/*Sort One and Two by Time*/ &lt;BR /&gt;
PROC SORT DATA = CONCAT OUT = CAT_SORT;&lt;BR /&gt;
	BY Time;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
Proc Print Data = CAT_SORT;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thius works well and the files get merged , the problem is that each row is repeated twice with the variables from the first file in the first line and the variable "Note" in the second line with the same variable "Time". So, if I need to export this in Excel then i get ,say, 400 rows when actually the count should be 200. Is there a way that the varible "Note" from second data is printed in the same line as are the other 5 variables from the first data ?&lt;BR /&gt;
&lt;BR /&gt;
Kindest Regards,&lt;BR /&gt;
Mark</description>
    <pubDate>Sun, 11 Jul 2010 19:26:23 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-07-11T19:26:23Z</dc:date>
    <item>
      <title>Merge/Concat</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-Concat/m-p/47115#M12617</link>
      <description>Hi,.&lt;BR /&gt;
&lt;BR /&gt;
I use the code to merge the two files , the code is -&lt;BR /&gt;
&lt;BR /&gt;
Data One;&lt;BR /&gt;
    INFILE "C:\sas\data_A.dat";&lt;BR /&gt;
    INPUT 	        Time         		 $1-8&lt;BR /&gt;
			Date                          $9-18&lt;BR /&gt;
			Model        		 $19-24&lt;BR /&gt;
			Unit   			  25-27&lt;BR /&gt;
			INT				  28;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc print data = Data One;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Data Two;&lt;BR /&gt;
	INFILE "C:\sas\data_B.dat";&lt;BR /&gt;
	INPUT 	Time 		 $1-8&lt;BR /&gt;
			Note         $9-16;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
PROC PRINT DATA = Two;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
/*Concatenate data One and Two*/&lt;BR /&gt;
data CONCAT;&lt;BR /&gt;
	SET One and Two;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
/*Sort One and Two by Time*/ &lt;BR /&gt;
PROC SORT DATA = CONCAT OUT = CAT_SORT;&lt;BR /&gt;
	BY Time;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
Proc Print Data = CAT_SORT;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thius works well and the files get merged , the problem is that each row is repeated twice with the variables from the first file in the first line and the variable "Note" in the second line with the same variable "Time". So, if I need to export this in Excel then i get ,say, 400 rows when actually the count should be 200. Is there a way that the varible "Note" from second data is printed in the same line as are the other 5 variables from the first data ?&lt;BR /&gt;
&lt;BR /&gt;
Kindest Regards,&lt;BR /&gt;
Mark</description>
      <pubDate>Sun, 11 Jul 2010 19:26:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-Concat/m-p/47115#M12617</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-07-11T19:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: Merge/Concat</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-Concat/m-p/47116#M12618</link>
      <description>I'm surprised that you didn't get an error from this step:&lt;BR /&gt;
&lt;BR /&gt;
/*Concatenate data One and Two*/&lt;BR /&gt;
data CONCAT;&lt;BR /&gt;
SET One and Two;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
"and" is treated as a separate dataset.&lt;BR /&gt;
&lt;BR /&gt;
Your PROC PRINT's also have incorrect syntax.&lt;BR /&gt;
&lt;BR /&gt;
The SET statement concatenates the two datasets.  Concatenate means to "stack" vertically.  If you want to string out two datasets to make longer rows, then you need the MERGE statement.  Probably something like this will work:&lt;BR /&gt;
&lt;BR /&gt;
PROC SORT DATA=one; BY time;  RUN;&lt;BR /&gt;
PROC SORT DATA=two, BY time; RUN;&lt;BR /&gt;
&lt;BR /&gt;
*Merge data One and Two;&lt;BR /&gt;
data CONCAT;&lt;BR /&gt;
MERGE One Two;&lt;BR /&gt;
BY time;&lt;BR /&gt;
RUN;</description>
      <pubDate>Sun, 11 Jul 2010 19:49:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-Concat/m-p/47116#M12618</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2010-07-11T19:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Merge/Concat</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-Concat/m-p/47117#M12619</link>
      <description>There are three key concepts here: merge, concatenate and interleave, for your consideration, depending on the output requirements, and also, as much, your input data and considering compatability (again, information given up in the SAS log).&lt;BR /&gt;
&lt;BR /&gt;
Recommended SAS support website - Google advanced search argument below this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
data step programming merge concatenate site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.

Message was edited by: sbb</description>
      <pubDate>Sun, 11 Jul 2010 20:49:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-Concat/m-p/47117#M12619</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-07-11T20:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: Merge/Concat</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-Concat/m-p/47118#M12620</link>
      <description>Hi:&lt;BR /&gt;
  In addition to Doc and Scott's suggestions, these previous forum postings both have concrete examples of concatenating versus merging SAS datasets:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=19272䭈" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=19272䭈&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=2613ਵ" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=2613ਵ&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 12 Jul 2010 14:53:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-Concat/m-p/47118#M12620</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-07-12T14:53:03Z</dc:date>
    </item>
  </channel>
</rss>

