<?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 Problem with SAS Match merging interleaving the data sets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-SAS-Match-merging-interleaving-the-data-sets/m-p/449366#M283593</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I am trying to merge three separate SAS datasets by two variables (ID Date)&amp;nbsp; that are present in all three datasets. Two of three datasets successfully match merge. However, when I try to merge the third dataset in, instead of doing a match merge, it interleaves the datasets. I have checked the formatting and lengths of the variables in the three datasets using proc contents and they appear to be the same. I even tried to redefine the format, length, and label for each dataset to ensure they were identical and I am still not having luck. Any suggestions? Below is an example of my merge code. Dataset 1 and 2 (infect.weights and infect.temperature) contain four variables (ID, Group, Date,Weight/Temperature). Dataset 2 (infect.counts) contains nine variables (ID, Date, X1-X7).&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 infect.weights;
 SET infect.weights;
 ATTRIB ID LENGTH=8 FORMAT=8. LABEL="ID";
 ATTRIB DATE LENGTH=8 FORMAT=MMDDYY10. LABEL="Date";
RUN;

DATA infect.temperature;
 SET infect.temperature;
 ATTRIB ID LENGTH=8 FORMAT=8. LABEL="ID";
 ATTRIB DATE LENGTH=8 FORMAT=MMDDYY10. LABEL="Date";
RUN;

DATA infect.cell;
 SET infect.qscout;
 
 ATTRIB ID LENGTH=8 FORMAT=8. LABEL="ID";
 ATTRIB DATE LENGTH=8 FORMAT=MMDDYY10. LABEL="Date";

RUN;

DATA parameters;
	MERGE infect.weights infect.temperature;
	BY ID Date;
RUN;

DATA parameters2;
	MERGE parameters infect.counts;
	BY ID Date;
RUN;

/* I have also tried to perform the merge within one data step and get the same results */ &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My Results end up looking like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ID    Group   Date                 Weight   Temp   X1    X2      X3    X4    X5    X6    X7
1          1      01/01/2001         100    100     .      .     .     .     .     .      .
1          1      01/01/2001            .     .     1      2     3     4     5     6      7 
2          1      01/01/2001         125    101     .      .      .    .     .     .      .
2          1      01/01/2001            .     .     8      9     10    11    12    13    14
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Mar 2018 15:08:44 GMT</pubDate>
    <dc:creator>HHutch</dc:creator>
    <dc:date>2018-03-28T15:08:44Z</dc:date>
    <item>
      <title>Problem with SAS Match merging interleaving the data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-SAS-Match-merging-interleaving-the-data-sets/m-p/449366#M283593</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I am trying to merge three separate SAS datasets by two variables (ID Date)&amp;nbsp; that are present in all three datasets. Two of three datasets successfully match merge. However, when I try to merge the third dataset in, instead of doing a match merge, it interleaves the datasets. I have checked the formatting and lengths of the variables in the three datasets using proc contents and they appear to be the same. I even tried to redefine the format, length, and label for each dataset to ensure they were identical and I am still not having luck. Any suggestions? Below is an example of my merge code. Dataset 1 and 2 (infect.weights and infect.temperature) contain four variables (ID, Group, Date,Weight/Temperature). Dataset 2 (infect.counts) contains nine variables (ID, Date, X1-X7).&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 infect.weights;
 SET infect.weights;
 ATTRIB ID LENGTH=8 FORMAT=8. LABEL="ID";
 ATTRIB DATE LENGTH=8 FORMAT=MMDDYY10. LABEL="Date";
RUN;

DATA infect.temperature;
 SET infect.temperature;
 ATTRIB ID LENGTH=8 FORMAT=8. LABEL="ID";
 ATTRIB DATE LENGTH=8 FORMAT=MMDDYY10. LABEL="Date";
RUN;

DATA infect.cell;
 SET infect.qscout;
 
 ATTRIB ID LENGTH=8 FORMAT=8. LABEL="ID";
 ATTRIB DATE LENGTH=8 FORMAT=MMDDYY10. LABEL="Date";

RUN;

DATA parameters;
	MERGE infect.weights infect.temperature;
	BY ID Date;
RUN;

DATA parameters2;
	MERGE parameters infect.counts;
	BY ID Date;
RUN;

/* I have also tried to perform the merge within one data step and get the same results */ &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My Results end up looking like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ID    Group   Date                 Weight   Temp   X1    X2      X3    X4    X5    X6    X7
1          1      01/01/2001         100    100     .      .     .     .     .     .      .
1          1      01/01/2001            .     .     1      2     3     4     5     6      7 
2          1      01/01/2001         125    101     .      .      .    .     .     .      .
2          1      01/01/2001            .     .     8      9     10    11    12    13    14
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 15:08:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-SAS-Match-merging-interleaving-the-data-sets/m-p/449366#M283593</guid>
      <dc:creator>HHutch</dc:creator>
      <dc:date>2018-03-28T15:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with SAS Match merging interleaving the data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-SAS-Match-merging-interleaving-the-data-sets/m-p/449380#M283594</link>
      <description>&lt;P&gt;What does the log show?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/174076"&gt;@HHutch&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I am trying to merge three separate SAS datasets by two variables (ID Date)&amp;nbsp; that are present in all three datasets. Two of three datasets successfully match merge. However, when I try to merge the third dataset in, instead of doing a match merge, it interleaves the datasets. I have checked the formatting and lengths of the variables in the three datasets using proc contents and they appear to be the same. I even tried to redefine the format, length, and label for each dataset to ensure they were identical and I am still not having luck. Any suggestions? Below is an example of my merge code. Dataset 1 and 2 (infect.weights and infect.temperature) contain four variables (ID, Group, Date,Weight/Temperature). Dataset 2 (infect.counts) contains nine variables (ID, Date, X1-X7).&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 infect.weights;
 SET infect.weights;
 ATTRIB ID LENGTH=8 FORMAT=8. LABEL="ID";
 ATTRIB DATE LENGTH=8 FORMAT=MMDDYY10. LABEL="Date";
RUN;

DATA infect.temperature;
 SET infect.temperature;
 ATTRIB ID LENGTH=8 FORMAT=8. LABEL="ID";
 ATTRIB DATE LENGTH=8 FORMAT=MMDDYY10. LABEL="Date";
RUN;

DATA infect.cell;
 SET infect.qscout;
 
 ATTRIB ID LENGTH=8 FORMAT=8. LABEL="ID";
 ATTRIB DATE LENGTH=8 FORMAT=MMDDYY10. LABEL="Date";

RUN;

DATA parameters;
	MERGE infect.weights infect.temperature;
	BY ID Date;
RUN;

DATA parameters2;
	MERGE parameters infect.counts;
	BY ID Date;
RUN;

/* I have also tried to perform the merge within one data step and get the same results */ &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My Results end up looking like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ID    Group   Date                 Weight   Temp   X1    X2      X3    X4    X5    X6    X7
1          1      01/01/2001         100    100     .      .     .     .     .     .      .
1          1      01/01/2001            .     .     1      2     3     4     5     6      7 
2          1      01/01/2001         125    101     .      .      .    .     .     .      .
2          1      01/01/2001            .     .     8      9     10    11    12    13    14
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;/LI-SPOILER&gt;</description>
      <pubDate>Wed, 28 Mar 2018 15:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-SAS-Match-merging-interleaving-the-data-sets/m-p/449380#M283594</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-28T15:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with SAS Match merging interleaving the data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-SAS-Match-merging-interleaving-the-data-sets/m-p/449386#M283595</link>
      <description>&lt;P&gt;The result you show indicates that the internal stored value of either ID or Date (or possibly both) varies somehow. If the variables are character look for blank characters such as a null at the end or beginning of the value.&lt;/P&gt;
&lt;P&gt;If numeric, check that there are not decimals in values that aren't displayed. Note that date values with decimals and assigned one of the SAS date formats will happily ignore the decimal portion for display but&amp;nbsp;use the entire value for comparisons such as merge or logic tests.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See:&lt;/P&gt;
&lt;PRE&gt;data example;
   date= '01Jan2018'd + 0.01;
   format date mmddyy10.;
run;
data example2;
   date= '01Jan2018'd ;
   format date mmddyy10.;
run;

data merged;
   merge example example2;
   by date;
run;&lt;/PRE&gt;
&lt;P&gt;I might try proc freq to display the ID or Date value&amp;nbsp;using a BEST12. or similar to see if decimals&amp;nbsp;are in your data. If so you might&amp;nbsp;try rounding the values in a&amp;nbsp;data step prior to the merge.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 22:07:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-SAS-Match-merging-interleaving-the-data-sets/m-p/449386#M283595</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-28T22:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with SAS Match merging interleaving the data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-SAS-Match-merging-interleaving-the-data-sets/m-p/449631#M283596</link>
      <description>&lt;P&gt;The log shows&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;327 DATA parameters2;&lt;BR /&gt;328 MERGE parameters infect.qscout;&lt;BR /&gt;329 BY ID Date;&lt;BR /&gt;330 RUN;&lt;/P&gt;&lt;P&gt;NOTE: There were 375 observations read from the data set WORK.PARAMETERS.&lt;BR /&gt;NOTE: There were 233 observations read from the data set INFECT.QSCOUT.&lt;BR /&gt;NOTE: The data set WORK.PARAMETERS2 has 608 observations and 12 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 12:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-SAS-Match-merging-interleaving-the-data-sets/m-p/449631#M283596</guid>
      <dc:creator>HHutch</dc:creator>
      <dc:date>2018-03-29T12:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with SAS Match merging interleaving the data sets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-SAS-Match-merging-interleaving-the-data-sets/m-p/449633#M283597</link>
      <description>&lt;P&gt;You were right! The one file's date contains values after the decimal point. I didn't realize the dataset it was being pulled from used a date/time format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help! It is greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 12:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-SAS-Match-merging-interleaving-the-data-sets/m-p/449633#M283597</guid>
      <dc:creator>HHutch</dc:creator>
      <dc:date>2018-03-29T12:50:43Z</dc:date>
    </item>
  </channel>
</rss>

