<?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 SAS Dataset issue in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Merge-SAS-Dataset-issue/m-p/59831#M16900</link>
    <description>Hi All,&lt;BR /&gt;
        I am creating a sas dataset 1 through the data file using Infile option and&lt;BR /&gt;
creating sas dataset 2 by pulling data from tables. When I do a merge I am having issue like even though the records are not matching , the result is showing as change. the code snippets are below:&lt;BR /&gt;
&lt;BR /&gt;
&lt;U&gt;Dataset 1&lt;/U&gt;:&lt;BR /&gt;
data old.test_file;&lt;BR /&gt;
infile samplefile lrecl=90 recfm=f;&lt;BR /&gt;
input @1 column1 $char1.&lt;BR /&gt;
        @2 column2 $char3.&lt;BR /&gt;
        @5 column3 $char26.&lt;BR /&gt;
        @31 column4 $char10.&lt;BR /&gt;
        @41 column5 $char50.&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;U&gt;Dataset 2&lt;/U&gt;:&lt;BR /&gt;
&lt;BR /&gt;
create table new.test_file as&lt;BR /&gt;
select * from connection to db2&lt;BR /&gt;
&lt;BR /&gt;
(select&lt;BR /&gt;
 cast(' ' as char(1)) as column1,&lt;BR /&gt;
 cast(' ' as char(3)) as column2,&lt;BR /&gt;
 cast(' ' as char(26)) as column3,&lt;BR /&gt;
 cast(' ' as char(10)) as column4,&lt;BR /&gt;
 cast(' ' as char(50)) as column5)&lt;BR /&gt;
from table name&lt;BR /&gt;
disconnect from DB2;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;U&gt;Merge operation&lt;/U&gt;:&lt;BR /&gt;
&lt;BR /&gt;
DATA change_records;&lt;BR /&gt;
merge old.test_file(IN=INOLD rename = (column1 = column1_o&lt;BR /&gt;
                                                           column2 = column2_o&lt;BR /&gt;
                                                           column3 = column3_o&lt;BR /&gt;
                                                           column4 = column4_o))&lt;BR /&gt;
                              new.test_file(IN=INNEW);&lt;BR /&gt;
 BY keycolumns;&lt;BR /&gt;
if INOLD and ~ INNEW then delete;&lt;BR /&gt;
 else if ~ INOLD and INNEW then delete;&lt;BR /&gt;
 else if INOLD AND INNEW&lt;BR /&gt;
 then do;&lt;BR /&gt;
  if column1 = column1_o and&lt;BR /&gt;
     column2 = column2_o and&lt;BR /&gt;
     column3 = column3_o and&lt;BR /&gt;
     column4 = column4_o and&lt;BR /&gt;
     column5 = column5_o&lt;BR /&gt;
then delete;&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
By using the above merge operation, I want to find the change records in both the datasets by matching through the KEY columns. But the result is , the change record it is showing in the output file is actually there is no change the datasets records. But it shows as change. I am not sure abt the reason. my vague quess would be the format issues, the data it is showing as change eventhough there is no change.&lt;BR /&gt;
&lt;BR /&gt;
Can somebody help on this. correct me if my approach is not correct.&lt;BR /&gt;
Thanks.</description>
    <pubDate>Wed, 05 Nov 2008 20:15:32 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-11-05T20:15:32Z</dc:date>
    <item>
      <title>Merge SAS Dataset issue</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-SAS-Dataset-issue/m-p/59831#M16900</link>
      <description>Hi All,&lt;BR /&gt;
        I am creating a sas dataset 1 through the data file using Infile option and&lt;BR /&gt;
creating sas dataset 2 by pulling data from tables. When I do a merge I am having issue like even though the records are not matching , the result is showing as change. the code snippets are below:&lt;BR /&gt;
&lt;BR /&gt;
&lt;U&gt;Dataset 1&lt;/U&gt;:&lt;BR /&gt;
data old.test_file;&lt;BR /&gt;
infile samplefile lrecl=90 recfm=f;&lt;BR /&gt;
input @1 column1 $char1.&lt;BR /&gt;
        @2 column2 $char3.&lt;BR /&gt;
        @5 column3 $char26.&lt;BR /&gt;
        @31 column4 $char10.&lt;BR /&gt;
        @41 column5 $char50.&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;U&gt;Dataset 2&lt;/U&gt;:&lt;BR /&gt;
&lt;BR /&gt;
create table new.test_file as&lt;BR /&gt;
select * from connection to db2&lt;BR /&gt;
&lt;BR /&gt;
(select&lt;BR /&gt;
 cast(' ' as char(1)) as column1,&lt;BR /&gt;
 cast(' ' as char(3)) as column2,&lt;BR /&gt;
 cast(' ' as char(26)) as column3,&lt;BR /&gt;
 cast(' ' as char(10)) as column4,&lt;BR /&gt;
 cast(' ' as char(50)) as column5)&lt;BR /&gt;
from table name&lt;BR /&gt;
disconnect from DB2;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;U&gt;Merge operation&lt;/U&gt;:&lt;BR /&gt;
&lt;BR /&gt;
DATA change_records;&lt;BR /&gt;
merge old.test_file(IN=INOLD rename = (column1 = column1_o&lt;BR /&gt;
                                                           column2 = column2_o&lt;BR /&gt;
                                                           column3 = column3_o&lt;BR /&gt;
                                                           column4 = column4_o))&lt;BR /&gt;
                              new.test_file(IN=INNEW);&lt;BR /&gt;
 BY keycolumns;&lt;BR /&gt;
if INOLD and ~ INNEW then delete;&lt;BR /&gt;
 else if ~ INOLD and INNEW then delete;&lt;BR /&gt;
 else if INOLD AND INNEW&lt;BR /&gt;
 then do;&lt;BR /&gt;
  if column1 = column1_o and&lt;BR /&gt;
     column2 = column2_o and&lt;BR /&gt;
     column3 = column3_o and&lt;BR /&gt;
     column4 = column4_o and&lt;BR /&gt;
     column5 = column5_o&lt;BR /&gt;
then delete;&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
By using the above merge operation, I want to find the change records in both the datasets by matching through the KEY columns. But the result is , the change record it is showing in the output file is actually there is no change the datasets records. But it shows as change. I am not sure abt the reason. my vague quess would be the format issues, the data it is showing as change eventhough there is no change.&lt;BR /&gt;
&lt;BR /&gt;
Can somebody help on this. correct me if my approach is not correct.&lt;BR /&gt;
Thanks.</description>
      <pubDate>Wed, 05 Nov 2008 20:15:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-SAS-Dataset-issue/m-p/59831#M16900</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-11-05T20:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: Merge SAS Dataset issue</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge-SAS-Dataset-issue/m-p/59832#M16901</link>
      <description>Recommend you post a SASLOG with some type of example condition.  Also, for your own diagnosis, add a SAS PUT _ALL_;  to your DATA step, but it will need to go prior to any OUTPUT / DELETE and also after your assignments.  I'm convinced this additional info (from the PUT) will help with debugging your SAS DATA step processing.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 06 Nov 2008 15:02:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge-SAS-Dataset-issue/m-p/59832#M16901</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-11-06T15:02:31Z</dc:date>
    </item>
  </channel>
</rss>

