SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmst_model_postcode_simBased.sas
1 /* ************************************************** *
2 * Model Post-Code Template *
3 * ************************************************** *
4
5 Purpose:
6 Injection point for executing custom code after the MIP model execution
7
8 Details:
9 The following SAS macro variables are available to the model at run time:
10 - ticket: SAS authentication service ticket (useful for performing operations that require authentication, i.e. interacting with REST services).
11 - rgf_protocol: Communication protocol (http/https) of the SAS Risk and Governance Framework web application
12 - rgf_host: Hostname of the SAS Risk and Governance Framework web application
13 - rgf_port: Port where the SAS Risk and Governance Framework web application is listening
14 - ds_in_model_result: Name of the input table containing the result of the MIP model execution
15 - ds_out_model_result: Name of the output table to be created by this code
16
17 * ************************************************** */
18
19
20 /*Process the the mip output (SIMSTAT) in order to extract the required information*/
21 /*notice that the collaterals need to be discarded as the they are not used to evaluate the EC.*/
22
23/* ********************************************* */
24/* Upload Data Script: Input Parameters */
25/* ********************************************* */
26
27/* Get the root location of the SAS Risk Workgroup Application */
28%let sas_risk_workgroup_dir = ${globals.sas_risk_workgroup_dir};
29
30/* Cycle Key */
31%let cycle_key = ${context.cycle.key};
32
33/* Analysis Run Key */
34%let analysis_run_key = ${context.analysisRun.key};
35
36
37%let current_dt_ymd = %sysfunc(date(), yymmddd10.);
38%let current_tm_tod = %sysfunc(time(), tod10.);
39
40%let custom_AnalysisName =${params.ANALYSISDATANAME};
41
42/* ********************************************* */
43
44%let ValueAtRisk_Level = ${params.VARLEVEL};
45
46/* Initialize the environment */
47%include "&sas_risk_workgroup_dir./groups/Public/SASRiskManagementCore/cycles/&cycle_key./init.sas" / lrecl = 32000 source2;
48
49
50/* Get information from the cycle */
51%let ticket =;
52%let httpSuccess = 0;
53%let responseStatus =;
54%irm_rest_get_rgf_cycle(key = &cycle_key.
55 , host = &rgf_protocol://&rgf_host.
56 , port = &rgf_port.
57 , tgt_ticket = &tgt_ticket.
58 , outds = cycle_info
59 , outVarTicket = ticket
60 , outSuccess = httpSuccess
61 , outResponseStatus = responseStatus
62 );
63data _null_;
64 set cycle_info;
65 call symputx("cycle_baseDt", baseDt, "L");
66 call symputx("cycle_entityId", entityId, "L");
67run;
68
69
70/*Retrieve results for credit risk detail*/
71data &ds_out_model_result.;
72 set &ds_in_model_result.(where=(collateral NE 1));
73 retain Economic_Capital . Component_Economic_Capital . ValueAtRisk . Component_ValueAtRisk . ExpectedLoss .;
74 by instid notsorted;
75 if simulationPart="VALUEATRISK" then ValueAtRisk=mean;
76 if simulationPart="ECONOMIC_CAPITAL" then Economic_Capital=mean;
77 if simulationPart="COMPONENT_VALUEATRISK" then Component_ValueAtRisk=mean;
78 if simulationPart="COMPONENT_ECONOMIC_CAPITAL" then Component_Economic_Capital=mean;
79 if simulationPart="EXPECTEDLOSS" then ExpectedLoss=mean;
80 ValueAtRisk_Alpha=&ValueAtRisk_Level.;
81 if last.instid then output;
82 drop mean;
83run;