Hi All,
I am creating a sas dataset 1 through the data file using Infile option and
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:
Dataset 1:
data old.test_file;
infile samplefile lrecl=90 recfm=f;
input @1 column1 $char1.
@2 column2 $char3.
@5 column3 $char26.
@31 column4 $char10.
@41 column5 $char50.
run;
Dataset 2:
create table new.test_file as
select * from connection to db2
(select
cast(' ' as char(1)) as column1,
cast(' ' as char(3)) as column2,
cast(' ' as char(26)) as column3,
cast(' ' as char(10)) as column4,
cast(' ' as char(50)) as column5)
from table name
disconnect from DB2;
quit;
Merge operation:
DATA change_records;
merge old.test_file(IN=INOLD rename = (column1 = column1_o
column2 = column2_o
column3 = column3_o
column4 = column4_o))
new.test_file(IN=INNEW);
BY keycolumns;
if INOLD and ~ INNEW then delete;
else if ~ INOLD and INNEW then delete;
else if INOLD AND INNEW
then do;
if column1 = column1_o and
column2 = column2_o and
column3 = column3_o and
column4 = column4_o and
column5 = column5_o
then delete;
end;
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.
Can somebody help on this. correct me if my approach is not correct.
Thanks.