BookmarkSubscribeRSS Feed
MG18
Lapis Lazuli | Level 10

Hi All, 

 

I am new to SAS AML but I do have basic understanding of BASE SAS ,SAS MACRO and SAS DI/BI.

Can somebody explain me how is scenario code SAS10006 will execute code is given below  ?

from where it will pick up values of variables like p10006_begin_date,run_scenario_init,n ,date_key array,account_type_desc{i}.

 

 

/*==============================================================================
| SAS SCENARIO FILE
|
| PRODUCT: SAS Anti-Money Laundering
| SYSTEM: UNIX/WINDOWS
================================================================================
| NAME: | SAS10006
| |
| CATEGORY: | Cash Activity
| |
| SEVERITY: | Scenario
| |
| FREQUENCY: | Daily
| |
| DURATION: | 5 days
| |
| SUBJECT: | Customer
| |
| PREP FILE: | PARTY_TRANSACTIONS
| |
| HEADER FILE: | party_header
| |
| TRIGGER: | Yes
| |
| DAYS CONSIDERED: | Business
================================================================================

SHORT DESCRIPTION
-----------------
Large Total Cash Transactions

DESCRIPTION
-----------
A customer's total amount of cash transactions exceeds a threshold over several
days.

BUSINESS NOTES
--------------
This scenario calculates the sum of a customer's cash credit and cash debit
transactions over a specified time period. If the total amount of the cash
transactions is greater than or equal to the specified threshold, a match is
found. This scenario considers both credit and debit cash transactions based on
business days. Related scenarios SAS10007 only considers cash deposits and
SAS10020 allows for examining multiple transaction types.

TECHNICAL NOTES
---------------
Not Applicable

MESSAGE
-------
r10006_threshold_message = %str("Total Cash Transactions = #$ #1;
Business Day Count = #2");

SAMPLE MESSAGE
--------------
Total Cash Transactions = USD 20,708; Business Day Count = 5

================================================================================
PARAMETERS

Name Type Default Value
---------------------------------|-------------------|--------------------------
p10006_account_type_desc | Character List | 'P'
p10006_cdi_indicator | Character List | 'C','D'
p10006_currency_acct | Character List | 'N'
p10006_num_days | Numeric Constant | 5
p10006_pri_medium_desc | Character List | 'CASH'
p10006_status_desc | Character List | 'SUCCESS'
p10006_trans_limit | Numeric Constant | 10000
p10006_trans_today | Numeric Constant | 2000
p10006_trans_total | Numeric Constant | 20000

Descriptions
------------
- p10006_account_type_desc
List denoting valid types of accounts

- p10006_cdi_indicator
List denoting credit and debit activities

- p10006_currency_acct
List denoting non-exempt accounts

- p10006_num_days
Number of business days in interval

- p10006_pri_medium_desc
List denoting currency activities

- p10006_status_desc
List denoting completed transactions

- p10006_trans_limit
Maximum single amount of a valid transaction in interval

- p10006_trans_today
Minimum aggregate amount of valid transactions on the current day

- p10006_trans_total
Minimum aggregate amount of valid credits

================================================================================

================================================================================
Copyright (c) 2012 by SAS Institute Inc., Cary, NC 27513 USA
- All rights reserved
==============================================================================*/

/*----------------------------------------------------------------------------
NOTE:> The statement below required for triggering transaction processing
------------------------------------------------------------------------------*/
%let this_macro_name = &sysmacroname; /* save this macro name */
/*----------------------------------------------------------------------------*/

retain p10006_begin_date;
format p10006_day_list $512.;

/* This init section should be placed before any goto statements. This section of
code will only be run when processing the first BY group of the prep data set.
Any goto statements placed before it may prevent the init code from being run. */
if run_scenario_init eq 1 then do;
p10006_begin_date = input(put(rundate_number-&p10006_num_days+1,num_to_date.),8.);
end;

/* Skip parties that do not have transactions on the current day */
if date_key{n} < rundate then goto &sysmacroname.;

p10006_day_list = ' ';
p10006_day_count = 0;
p10006_todays_total = 0;
p10006_total_amount = 0;

do i = n to 1 by -1 until(date_key{i} < p10006_begin_date);
if p10006_begin_date <= date_key{i} <= rundate then do;
if upcase(account_type_desc{i}) in (&p10006_account_type_desc) and
upcase(currency_based_account_ind{i}) in (&p10006_currency_acct) and
upcase(primary_medium_desc{i}) in (&p10006_pri_medium_desc) and
upcase(transaction_cdi_code{i}) in (&p10006_cdi_indicator) and
upcase(status_desc{i}) in (&p10006_status_desc)
then do;
if currency_amount{i} gt &p10006_trans_limit then goto &sysmacroname.;
%save_transaction_key (calling_macro=&this_macro_name);
p10006_total_amount = sum(p10006_total_amount,currency_amount{i});
repeat = indexw(p10006_day_list,strip(put(date_key{i},8.)));
if repeat eq 0 and not missing(date_key{i}) then do;
p10006_day_list = catx(' ',p10006_day_list,put(date_key{i},8.));
p10006_day_count + 1;
end;
if date_key{i} = rundate then
p10006_todays_total = sum(p10006_todays_total,currency_amount{i});
end;
end;
end;

/* Compare party values to parameters for a match */
if p10006_todays_total ge &p10006_trans_today and
p10006_total_amount ge &p10006_trans_total then do;
actual_values_text = tranwrd(&r10006_threshold_message,'#1',strip(put(p10006_total_amount,nlnum32.)) );
actual_values_text = tranwrd(actual_values_text,'#2',strip(put(p10006_day_count,nlnum32.)) );
actual_values_text = tranwrd(actual_values_text,'#$', "&currency_code" );
output &alert_fname;
end;

/* EXIT */
&sysmacroname.:;


/* ========================================================================== */
/* END SCENARIO - SAS10006 */
/* ========================================================================== */

5 REPLIES 5
MG18
Lapis Lazuli | Level 10

from where it will pick up values of variables like p10006_begin_date,run_scenario_init,n ,date_key array,account_type_desc{i} ?

where those values are stored ? what will be the input dataset for scenario SAS10006.

Kurt_Bremser
Super User

As I already said, that's up to the data step in which this macro is used. You have to look there. On it's own, the definition of a macro does NOTHING.

MG18
Lapis Lazuli | Level 10

Can you please tell where is the macro definition for this %save_transaction_key ?

and what is use of it ? will it save any transaction where is it satisfying condition ?

 

UrvishShah
Fluorite | Level 6

Hi,

 

The scenario code which you are seeing is the part of SAS Data Step (SET statement inside it). This scenario code is being called in datastep as explained in previous comments. 

 

I can only tell, this is typically the SAS AML design of writing scenario codes by using SAS Arrays, SAS Hash and SAS Hash Hiter programming. More information can be found in SAS AML user's guide. 

 

Hope it helps!!!

 

-Urvish

 

 

 

 

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!

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
  • 5 replies
  • 2608 views
  • 1 like
  • 3 in conversation