BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Mixer
Obsidian | Level 7

Hi All,

 

Would someone please explain how the missing records section work? Thank you for your help.

 

 

declare hash hct(dataset: 'work.etls_compare_digest', hashexp: 10);
hct.defineKey("sourcedb_id", "case_id");
hct.defineData("sourcedb_id", "case_id", "compare_digest");
hct.defineDone();
end;

set work.W1PAEO8L end = eof;

/* create digest - version 2.1 */
source_digest = put(md5(catq(' ', contact_id, subject_id, owner_id, owner_name, case_name, Season,
case_priority, case_notes, case_state_code, case_status_code,
case_status_desc)), $hex32.);

/* source/compare match */
if hct.find() eq 0 then
do;
/* source/compare match: Unchanged records */
if source_digest eq compare_digest then
output work.WGK73ZRO;

/* source/compare match: Changed records */
else if source_digest ne compare_digest then
output work.WGK73X4D;

/* remove found key + data */
hct.remove();
end;
/* source table: New records */
else if hct.find() ne 0 then
output work.WGK73YG2;

/* Missing records */
if eof then
rc = hct.output(dataset: 'work.WGK7411D(drop = compare_digest)');

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You told SAS to set a flag when your were reading the last observation in your SET statement.

set work.W1PAEO8L end = eof;

Then when you get to the last observation you write out the remain records from the hash object. You ave added dataset options to drop one of the variables.

if eof then
  rc = hct.output(dataset: 'work.WGK7411D(drop = compare_digest)')
;

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

You told SAS to set a flag when your were reading the last observation in your SET statement.

set work.W1PAEO8L end = eof;

Then when you get to the last observation you write out the remain records from the hash object. You ave added dataset options to drop one of the variables.

if eof then
  rc = hct.output(dataset: 'work.WGK7411D(drop = compare_digest)')
;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 392 views
  • 1 like
  • 2 in conversation