SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irm_setup.sas
Go to the documentation of this file.
1/*
2 Copyright (C) 2015 SAS Institute Inc. Cary, NC, USA
3*/
4
5/**
6 \file
7
8 \brief This macro initializes the IRM environment
9
10 \ingroup development
11
12 \param [in] env_path Path to the root folder of the data environment - this would be the folder that contains the landing_area
13 \param [in] source_path Path to the root folder of the Federated Content Area (root folder, excluding the Federated Content folder)
14 \param [in] fa_id Name of the Federated Content folder
15 \param [in] config_set_id Configuration Set Id. Determines which configuration tables the libraries will point to.
16 \param [in] base_dt Base Date (format: DDMMMYYY) - mutual exclusive use with base_dttm
17 \param [in] base_dttm Base Datetime (format: DDMMMYYYY:HH:MM:SS) - mutual exclusive use with base_dt
18 \param [in] setupLUA determines if LUA must be set up (Y) or not (N) - Default is Y
19 \param [in] live_ETL determines whether to use the input_area introduced in IRM 3.4 (N = legacy behaviour thus data loaded directly in landing area)
20 \param [in] (Optional) landing_area_folder Folder in the landing_area/input_area where the data resides. This would typically be a scenario name. Leave empty when not relevant.
21
22 \details This macro declares the following SAS libraries:
23 - FW_IN -> Stores all historical input data
24 - FW_GBL -> Global parameter tables
25 - LA_STAT -> Configuration tables
26 - LA_MAP -> Mapping tables
27 - LA_STAGE -> Staging tables (in landing area - subset of the input data for a given base date)
28 - IA_STAGE -> Staging tables (in input area - subset of the input data for a given base date - only when live_ETL = Y)
29
30 \author SAS Institute Inc.
31 \date 2015
32*/
33
34
35%macro irm_setup(env_path =
36 , source_path =
37 , fa_id =
38 , config_set_id =
39 , base_dt =
40 , base_dttm =
41 , setupLUA = Y
42 , live_ETL = Y
43 , landing_area_folder =
44 , rmc_fa_id = rmc.*
45 , rmc_fa_path =
46 );
47 %local
48 libpath
49 existing_lua
50 lua_insert
51 rmc_lua_path
52 ;
53
54 /* Remove the fa_id from the source_path if it is already included (as a leaf folder) */
55 %if(%sysevalf(%superq(fa_id) ne, boolean)) %then
56 %let source_path = %sysfunc(prxchange(s/([\\\/]&fa_id.)?[\\\/]*$//, 1, &source_path.));
57
58 /* If missing, set the value of env_path to the location of the federated area */
59 %if (%length(&env_path.) = 0) %then
60 %let env_path = &source_path./&fa_id.;
61
62 /* Make sure the rmc_fa_id parameter has been set */
63 %if %sysevalf(%superq(rmc_fa_id) =, boolean) %then
64 %let rmc_fa_id = rmc.*;
65
66 /* ***************************************************************************/
67 /* Update sasautos and setup LUA paths */
68 /* ***************************************************************************/
69 %if(%length(&source_path.)) %then %do;
70
71 /* Add macros to the auto search path */
72 options insert = (sasautos = ("&source_path./&fa_id./source/sas/ucmacros"));
73
74 %if %sysevalf(%superq(rmc_fa_path) =, boolean) %then %do;
75 %put NOTE: Input parameter RMC_FA_PATH has not been set.;
76 %put NOTE: Fetching RMC federated area location from metadata searching for IRM Mid-Tier Server property: com.sas.solutions.risk.irm.fa.&rmc_fa_id.;
77 %end;
78
79 /* Set SASAUTOS for RMC */
80 %irm_set_fa_sasautos(fa_id = &rmc_fa_id.
81 , fa_path = &rmc_fa_path.
82 , mode = insert
83 , insert_after = &source_path./&fa_id.
84 , limit = 1
85 , outvar_prefix = irm_setup_rmc_fa
86 );
87
88 /* Throw a warning if we haven't found any RMC federated area */
89 %if(&irm_setup_rmc_fa_count. = 0) %then
90 %put WARNING: Could not find any federated area with id: com.sas.solutions.risk.irm.fa.&rmc_fa_id.;
91
92 %if %upcase(&setupLUA.) = Y %then %do;
93
94 /* Usee the rmc_fa_path if it has been provided */
95 %if %sysevalf(%superq(rmc_fa_path) ne, boolean) %then
96 %let rmc_lua_path = &rmc_fa_path./source/lua;
97
98 /* Set LUAPATH for the current FA */
99 %irm_set_fa_luapath(fa_path = &source_path./&fa_id./source/lua
100 , mode = insert
101 );
102
103 /* Add RMC to the LUAPATH */
104 %irm_set_fa_luapath(fa_id = &rmc_fa_id.
105 , fa_path = &rmc_lua_path.
106 , mode = insert
107 , insert_after = &source_path./&fa_id.
108 , limit = 1
109 );
110
111 %end;
112 %end;
113
114 /* ***************************************************************************/
115 /* Declare libraries in Read/Write mode (create folders if they don't exist) */
116 /* ***************************************************************************/
117
118 /* Input Data (full history) */
119 %let libpath = &env_path./input;
120 %rsk_mkdirs_and_verify(&libpath.);
121 %rsk_allocate_data_mart_lib(libref = in_data, dir = &libpath., allochow = RW);
122
123 /* Landing Area -> Global Parameters */
124 %let libpath = &env_path./landing_area/base/global;
125 %rsk_mkdirs_and_verify(&libpath.);
126 %rsk_allocate_data_mart_lib(libref = la_gbl, dir = &libpath., allochow = RW);
127
128 %if(%length(&config_set_id.)) %then %do;
129 /* Landing Area -> Configuration */
130 %let libpath = &env_path./landing_area/base/%lowcase(&config_set_id.)/static;
131 %rsk_mkdirs_and_verify(&libpath.);
132 %rsk_allocate_data_mart_lib(libref = la_stat, dir = &libpath., allochow = RW);
133
134 /* Landing Area -> Mapping */
135 %let libpath = &env_path./landing_area/base/%lowcase(&config_set_id.)/mapping;
136 %rsk_mkdirs_and_verify(&libpath.);
137 %rsk_allocate_data_mart_lib(libref = la_map, dir = &libpath., allochow = RW);
138 %end;
139
140 %if %sysevalf(%superq(base_dt)^=,boolean) %then %do;
141
142 /* Landing Area -> Staging */
143 %if %sysevalf(%superq(landing_area_folder)^=,boolean) %then %do;
144 %let libpath1 = &env_path./landing_area/%sysfunc(putn("&base_dt."d, mmddyyn8.))/&landing_area_folder.;
145 %let libpath2 = &env_path./landing_area/%sysfunc(putn("&base_dt."d, mmddyyn8.));
146 %end;
147 %else
148 %let libpath1 = &env_path./landing_area/%sysfunc(putn("&base_dt."d, mmddyyn8.));
149 %rsk_mkdirs_and_verify(&libpath1.);
150 %rsk_allocate_data_mart_lib(libref = la_stage, dir = &libpath1., allochow = RW);
151 %if %sysevalf(%superq(landing_area_folder)^=,boolean) %then
152 %rsk_allocate_data_mart_lib(libref = la_stgrt, dir = &libpath2., allochow = RW);
153
154 %end;
155 %else %if %sysevalf(%superq(base_dttm)^=,boolean) %then %do;
156
157 data _null_;
158 day = put(datepart("&base_dttm."dt), mmddyyn8.);
159 time = compress(put(timepart("&base_dttm."dt), time8.), ":");
160 call symputx("daytime", cats(day, time));
161 run;
162
163 /* Landing Area -> Staging */
164 %if %sysevalf(%superq(landing_area_folder)^=,boolean) %then %do;
165 %let libpath1 = &env_path./landing_area/&daytime/&landing_area_folder.;
166 %let libpath2 = &env_path./landing_area/&daytime;
167 %end;
168 %else
169 %let libpath1 = &env_path./landing_area/&daytime;
170 %rsk_mkdirs_and_verify(&libpath1.);
171 %rsk_allocate_data_mart_lib(libref = la_stage, dir = &libpath1., allochow = RW);
172 %if %sysevalf(%superq(landing_area_folder)^=,boolean) %then
173 %rsk_allocate_data_mart_lib(libref = la_stgrt, dir = &libpath2., allochow = RW);
174 %end;
175
176 /* ******************************************************************************/
177 /* Optionally, create the input_area folders */
178 /* ******************************************************************************/
179
180 %if &live_ETL eq Y %then %do;
181
182 %if %sysevalf(%superq(base_dt)^=,boolean) %then %do;
183
184 /* Input Area -> Staging */
185 %if %sysevalf(%superq(landing_area_folder)=,boolean) %then
186 %let libpath1 = &env_path./input_area/%sysfunc(putn("&base_dt."d, mmddyyn8.));
187 %else %do;
188 %let libpath1 = &env_path./input_area/%sysfunc(putn("&base_dt."d, mmddyyn8.))/&landing_area_folder.;
189 %let libpath2 = &env_path./input_area/%sysfunc(putn("&base_dt."d, mmddyyn8.));
190 %end;
191 %rsk_mkdirs_and_verify(&libpath1.);
192 %rsk_allocate_data_mart_lib(libref = ia_stage, dir = &libpath1., allochow = RW);
193 %if %sysevalf(%superq(landing_area_folder)^=,boolean) %then
194 %rsk_allocate_data_mart_lib(libref = la_stgrt, dir = &libpath2., allochow = RW);
195
196 %end;
197 %else %if %sysevalf(%superq(base_dttm)^=,boolean) %then %do;
198
199 data _null_;
200 day = put(datepart("&base_dttm."dt), mmddyyn8.);
201 time = compress(put(timepart("&base_dttm."dt), time8.), ":");
202 call symputx("daytime", cats(day, time));
203 run;
204
205 /* Input Area -> Staging */
206 %if %sysevalf(%superq(landing_area_folder)=,boolean) %then
207 %let libpath1 = &env_path./input_area/&daytime;
208 %else %do;
209 %let libpath1 = &env_path./input_area/&daytime/&landing_area_folder.;
210 %let libpath2 = &env_path./input_area/&daytime;
211 %end;
212 %rsk_mkdirs_and_verify(&libpath1.);
213 %rsk_allocate_data_mart_lib(libref = ia_stage, dir = &libpath1., allochow = RW);
214 %if %sysevalf(%superq(landing_area_folder)^=,boolean) %then
215 %rsk_allocate_data_mart_lib(libref = la_stgrt, dir = &libpath2., allochow = RW);
216 %end;
217
218 %end;
219
220
221
222%mend;