This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*--- setup unit test; | |
%let source_dir = /user/SASTest/source; | |
%let target_dir = /user/SASTest/target; | |
x "mkdir -p &source_dir."; | |
x "mkdir -p &target_dir."; | |
libname srclib "&source_dir."; | |
libname tgtlib "&target_dir."; | |
proc datasets lib=srclib kill nolist; run; quit; | |
proc datasets lib=tgtlib kill nolist; run; quit; | |
libname srclib clear; | |
libname tgtlib clear; | |
*--- define source table; | |
libname srclib "&source_dir." compress=yes; | |
data srclib.customer_details; | |
infile datalines dlm="|"; | |
format customer_id 8. customer_name $100. customer_dob date9. customer_address $200.; | |
input customer_id customer_name $ customer_dob date9. customer_address; | |
datalines; | |
9900001|Sarah Smith|23JUN1987|123 River Drive, Hamilton, HA01 5TH Testland | |
9900002|Matthew Round|02MAR2000|456 Busy Street, New Thems, TH23 7UL Testland | |
; | |
run; | |
title "00. Source Table"; | |
proc print data=srclib.customer_details; run; | |
libname srclib clear; | |
data _null_; s = sleep(2,1); run; | |
*--- initial run; | |
libname srclib "&source_dir." access=readonly; | |
libname tgtlib "&target_dir." compress=yes; | |
%scd2(srclib,customer_details,customer_id,tgtlib,customer_details); | |
title "01. Initial Run"; | |
proc sort data=tgtlib.customer_details; by customer_id db_update_dt; run; | |
proc print data=tgtlib.customer_details; run; | |
libname srclib clear; | |
libname tgtlib clear; | |
data _null_; s = sleep(2,1); run; | |
*--- no changes; | |
libname srclib "&source_dir." access=readonly; | |
libname tgtlib "&target_dir." compress=yes; | |
%scd2(srclib,customer_details,customer_id,tgtlib,customer_details); | |
title "02. No Changes"; | |
proc sort data=tgtlib.customer_details; by customer_id db_update_dt; run; | |
proc print data=tgtlib.customer_details; run; | |
libname srclib clear; | |
libname tgtlib clear; | |
data _null_; s = sleep(2,1); run; | |
*--- define address change table; | |
libname srclib "&source_dir." compress=yes; | |
data srclib.customer_details; | |
infile datalines dlm="|"; | |
format customer_id 8. customer_name $100. customer_dob date9. customer_address $200.; | |
input customer_id customer_name $ customer_dob date9. customer_address; | |
datalines; | |
9900001|Sarah Smith|23JUN1987|123 River Drive, Hamilton, HA01 5TH Testland | |
9900002|Matthew Round|02MAR2000|9 Hill Road, Brid, BD05 1HL Testland | |
; | |
run; | |
title "03. Address Change Table"; | |
proc print data=srclib.customer_details; run; | |
libname srclib clear; | |
data _null_; s = sleep(2,1); run; | |
*--- address change; | |
libname srclib "&source_dir." access=readonly; | |
libname tgtlib "&target_dir." compress=yes; | |
%scd2(srclib,customer_details,customer_id,tgtlib,customer_details); | |
title "04. Address Change"; | |
proc sort data=tgtlib.customer_details; by customer_id db_update_dt; run; | |
proc print data=tgtlib.customer_details; run; | |
libname srclib clear; | |
libname tgtlib clear; | |
data _null_; s = sleep(2,1); run; | |
*--- no changes; | |
libname srclib "&source_dir." access=readonly; | |
libname tgtlib "&target_dir." compress=yes; | |
%scd2(srclib,customer_details,customer_id,tgtlib,customer_details); | |
title "05. No Changes"; | |
proc sort data=tgtlib.customer_details; by customer_id db_update_dt; run; | |
proc print data=tgtlib.customer_details; run; | |
libname srclib clear; | |
libname tgtlib clear; | |
data _null_; s = sleep(2,1); run; | |
*--- define new customer table; | |
libname srclib "&source_dir." compress=yes; | |
data srclib.customer_details; | |
infile datalines dlm="|"; | |
format customer_id 8. customer_name $100. customer_dob date9. customer_address $200.; | |
input customer_id customer_name $ customer_dob date9. customer_address; | |
datalines; | |
9900001|Sarah Smith|23JUN1987|123 River Drive, Hamilton, HA01 5TH Testland | |
9900002|Matthew Round|02MAR2000|9 Hill Road, Brid, BD05 1HL Testland | |
9900003|Jemma Hilderson|13FEB1975| | |
9900004|Thomas Hilderson|26APR1976| | |
; | |
run; | |
title "06. New Customer Table"; | |
proc print data=srclib.customer_details; run; | |
libname srclib clear; | |
data _null_; s = sleep(2,1); run; | |
*--- new customer change; | |
libname srclib "&source_dir." access=readonly; | |
libname tgtlib "&target_dir." compress=yes; | |
%scd2(srclib,customer_details,customer_id,tgtlib,customer_details); | |
title "07. New Customer Change"; | |
proc sort data=tgtlib.customer_details; by customer_id db_update_dt; run; | |
proc print data=tgtlib.customer_details; run; | |
libname srclib clear; | |
libname tgtlib clear; | |
data _null_; s = sleep(2,1); run; | |
*--- no changes; | |
libname srclib "&source_dir." access=readonly; | |
libname tgtlib "&target_dir." compress=yes; | |
%scd2(srclib,customer_details,customer_id,tgtlib,customer_details); | |
title "08. No Changes"; | |
proc sort data=tgtlib.customer_details; by customer_id db_update_dt; run; | |
proc print data=tgtlib.customer_details; run; | |
libname srclib clear; | |
libname tgtlib clear; | |
data _null_; s = sleep(2,1); run; | |
*--- define delete customer table; | |
libname srclib "&source_dir." compress=yes; | |
data srclib.customer_details; | |
infile datalines dlm="|"; | |
format customer_id 8. customer_name $100. customer_dob date9. customer_address $200.; | |
input customer_id customer_name $ customer_dob date9. customer_address; | |
datalines; | |
9900001|Sarah Smith|23JUN1987|123 River Drive, Hamilton, HA01 5TH Testland | |
9900003|Jemma Hilderson|13FEB1975| | |
9900004|Thomas Hilderson|26APR1976| | |
; | |
run; | |
title "09. Delete Customer Table"; | |
proc print data=srclib.customer_details; run; | |
libname srclib clear; | |
data _null_; s = sleep(2,1); run; | |
*--- delete customer change; | |
libname srclib "&source_dir." access=readonly; | |
libname tgtlib "&target_dir." compress=yes; | |
%scd2(srclib,customer_details,customer_id,tgtlib,customer_details); | |
title "10. Delete Customer"; | |
proc sort data=tgtlib.customer_details; by customer_id db_update_dt; run; | |
proc print data=tgtlib.customer_details; run; | |
libname srclib clear; | |
libname tgtlib clear; | |
data _null_; s = sleep(2,1); run; | |
*--- define delete customer table; | |
libname srclib "&source_dir." compress=yes; | |
data srclib.customer_details; | |
infile datalines dlm="|"; | |
format customer_id 8. customer_name $100. customer_dob date9. customer_address $200.; | |
input customer_id customer_name $ customer_dob date9. customer_address; | |
datalines; | |
9900003|Jemma Hilderson|13FEB1975|15 Main Road, South Bank, SB07 7MR Testland | |
9900004|Thomas Hilderson|26APR1976|15 Main Road, South Bank, SB07 7MR Testland | |
9900005|Harry Octamo|3MAY2000|Apt 9 Seaview Apartments 1020 Board Drive, London, LN34 3BD, Testland | |
; | |
run; | |
title "11. Multi Address Update. Delete, New Table"; | |
proc print data=srclib.customer_details; run; | |
libname srclib clear; | |
data _null_; s = sleep(2,1); run; | |
*--- delete customer change; | |
libname srclib "&source_dir." access=readonly; | |
libname tgtlib "&target_dir." compress=yes; | |
%scd2(srclib,customer_details,customer_id,tgtlib,customer_details); | |
title "12. Multi Address Update. Delete, New"; | |
proc sort data=tgtlib.customer_details; by customer_id db_update_dt; run; | |
proc print data=tgtlib.customer_details; run; | |
libname srclib clear; | |
libname tgtlib clear; | |
data _null_; s = sleep(2,1); run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment