BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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.
1 REPLY 1
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.

Scott Barry
SBBWorks, Inc.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 601 views
  • 0 likes
  • 2 in conversation