SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmc_cf_eliminated_remap.sas
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 SAS Institute Inc. Cary, NC, USA
3 */
4
5/**
6 \file
7
8 \anchor irmc_cf_eliminated_remap
9
10 \brief It creates a cash flow data set associated with positions selected for elimination.
11
12 \param[in] ds_in_cf Input cash flow table.
13 \param[in] ds_in_short_position Input short positions.
14 \param[in] working_libname Working libnames
15 \param[out] ds_out Output table containing the cash flow associated with the short positions.
16
17
18
19
20
21
22
23
24
25 \details
26
27 Given an input cash flow table (<i>DS_IN_CF</i>) and a map (<i>DS_IN_SHORT_POSITION</i>) that connects the original INSTIDs
28 of the eliminated positions and the new INSTIDs derived from the elimination, it creates a cash flow data set for the positions selected for elimination.
29
30
31
32
33
34 The structure of the <b><i>DS_IN_CF</i></b> table is as follows:
35
36 | Variable | Type | Description |
37 |------------------------------|-------------------|-----------------------------------------------------------------------------------------------------------------|
38 | <i>&lt;INSTID&gt;</i> | CHARACTER | Cash-Flow identifier variable. |
39 | Other Variables | CHARACTER/NUMERIC | Other variables not relevant for the merge |
40
41 The structure of the <b><i>DS_IN_SHORT_POSITION</i></b> table is as follows:
42
43 | Variable | Type | Description |
44 |--------------------------------------|--------------------|-----------------------------------------------------------------------------|
45 | <i>&lt;INSTID&gt;</i> | CHARACTER | Instrument identifier variable. |
46 | <i>&lt;ORIG_INSTID&gt;</i> | CHARACTER | Instrument original identifier variable. |
47
48
49
50
51 \ingroup DynamicPortfolio
52
53 \author SAS Institute INC.
54 \date 2020
55
56*/
57
58
59%macro irmc_cf_eliminated_remap( ds_in_cf =
60 , ds_in_short_position =
61 , working_libname = work
62 , ds_out =
63 );
64
65
66 /*Extract the cash the cash flow associated with position selected for elimination*/
67 data &working_libname..eliminated_cf;
68 set &ds_in_cf.;
69 if _n_=1 then do;
70 declare hash h_eliminated(dataset: "&ds_in_short_position.(drop=instid rename=(orig_instid=instid)");
71 h_eliminated.definekey("instid");
72 h_eliminated.definedone();
73 end;
74 rc_eliminated=h_eliminated.find();
75 if rc_eliminated=0 then output;
76 drop rc_eliminated;
77 run;
78
79
80 /*Merge the cash flow associated with positions selected for elimination together
81 with the table containining a map between the original instid of the eliminated positions and the new name drived from
82 the eleimination. The resultin cash flow table is a full join that expands the original cash flow across the new
83 instids induced by the elimination.*/
84 proc sql;
85 create table &ds_out. as
86 select A.instid, A.orig_instid, b.*
87 from &ds_in_short_position. A full join &working_libname..eliminated_cf B
88 on A.orig_instid = B.instid;
89 quit;
90
91 data &ds_out.;
92 set &ds_out.;
93 if ((valDate ne .) and (valType ne "") and (valAmount ne .)) then output;
94 run;
95
96
97%mend irmc_cf_eliminated_remap;
98
99
100
101
102
103