This code consists of two SQL procedures written in SAS,...
September 3, 2025 at 11:50 PM
This code consists of two SQL procedures written in SAS, and here's an explanation of what each block does:
First SQL Block: Creating recov_dup_import
Table
-
Purpose of Query:
- This SQL block creates a new table,
recov_dup_import
, by joining data from two tables:temp.recov_dup_exp
(a
) andDDWV01.LOAN_INFO_TACT
(b
). - It aims to calculate recovery-related metrics (
PREV_RECOV_DATE
,PREV_TOTAL_RECOV
,mtd_recov
,UNCONVERTED_MTD_RECOV
) by incorporating additional fields fromb
intoa
.
- This SQL block creates a new table,
-
Details of the Query:
- Columns from table
a
are selected, including recovery details (e.g.,TOTAL_RECOV
,RECOV_DATE
), account details (olbb_account
,olbb_seg
), and other data. - Fields from table
b
(LST_WRTOF_RCVRY_DT
andLIFETIME_WO_RCVRY_AMT
) are used as lookup values:PREV_RECOV_DATE
: Set toLST_WRTOF_RCVRY_DT
, representing the previous recovery date.PREV_TOTAL_RECOV
: Set toLIFETIME_WO_RCVRY_AMT
, representing the total recovery amount so far.mtd_recov
: Calculated as the difference between current recovery amount (TOTAL_RECOV
) and lifetime recovery (LIFETIME_WO_RCVRY_AMT
), i.e., month-to-date recovery.UNCONVERTED_MTD_RECOV
: Same asmtd_recov
.
- Columns from table
-
Join Condition:
- This is a
LEFT JOIN
between:a.clnt_no
andb.ip_id
(which is converted to numeric usinginput
andput
).- A substring comparison of
ar_id
fields ina
andb
(substr(ar_id,10,12)
). - Matching
SNAP_DT
fromb
with the macro variable&lmthend.
(representing some specific snapshot date).
- This is a
Second SQL Block: Creating recov_non_dup_1
Table
-
Purpose of Query:
- This block filters out non-duplicate records from
Edw_mtd_loan_recov_12
table by comparing it with therecov_dup_import
table generated previously.
- This block filters out non-duplicate records from
-
Details of the Query:
- The query selects all columns (
a.*
) from the tableEdw_mtd_loan_recov_12
(a
), excluding rows that have the sameolbb_account
andolbb_seg
values as those inrecov_dup_import
(b
). - The
LEFT JOIN
identifies matching rows based onolbb_account
andolbb_seg
. - The
WHERE
condition ensures that only non-matching (<>
) rows froma
are included in the output.
- The query selects all columns (
-
Result:
- The resulting table
recov_non_dup_1
contains recovery data without duplicates (based on theolbb_account
andolbb_seg
combination).
- The resulting table
Overall Functionality
- The first block creates a table combining recovery-related metrics and historical recovery data from two sources, performing calculations for metrics like month-to-date recovery (
mtd_recov
). - The second block filters non-duplicate recovery records from a separate table (
Edw_mtd_loan_recov_12
) by ensuring no overlap with the previously createdrecov_dup_import
table based on specified columns (olbb_account
,olbb_seg
).
The code integrates, processes, and de-duplicates recovery data for further analysis or reporting.
Generate your own explanations
Download our vscode extension
Read other generated explanations
Built by @thebuilderjr
Sponsored by beam analytics
Read our terms and privacy policy
Forked from openai-quickstart-node