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)');
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)')
;
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)')
;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.