SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmst_script_init.sas
1/* ********************************************* */
2/* Init Script: Input Parameters */
3/* ********************************************* */
4
5/* RGF Connection parameters */
6%let rgf_protocol = ${globals.protocol};
7%let rgf_host = ${globals.host};
8%let rgf_port = ${globals.port};
9%let rgf_service = ${globals.service};
10%let rgf_solution = ${globals.contentId};
11%let rmc_fa_id = ${context.cycle.rmcVersionNm};
12
13/* Get the root location of the SAS Risk Workgroup Application */
14%let sas_risk_workgroup_dir = ${globals.sas_risk_workgroup_dir};
15
16/* TGT Authentication Ticket */
17%let rgf_tgt_ticket = ${globals.ticket};
18
19/* Cycle Id */
20%let cycle_id = ${context.cycle.key};
21
22/* Cycle Name */
23%let cycle_name = %nrbquote(${context.cycle.name});
24
25/* Analysis Run Id */
26%let analysis_run_id = ${context.analysisRun.key};
27
28/* Entity Id */
29%let entity_id = ${context.cycle.entityId};
30
31/* Federated Area Id */
32%let irm_fa_id = ${context.cycle.versionNm};
33
34/* Base Date (format: YYYY-MM-DDZ) */
35%let base_dt = ${context.cycle.baseDt};
36
37/* Log Level: 1-4 */
38%let log_level = ${params.LOGLEVEL};
39
40/* ********************************************* */
41
42
43/* ********************************************* */
44/* Content specific parameters */
45/* ********************************************* */
46%let perspectiveId = ${context.cycle.solutionCreatedIn};
47%let solutionId = ST;
48%let solutionShortName = Stress Testing;
49%let solutionName = SAS Solution for Stress Testing;
50%let solutionLibrefPrefix = ST;
51/* ********************************************* */
52
53
54/* Get the location to the IRM Federated Area */
55%let irm_fa_path = %sysfunc(metadata_appprop(IRM Mid-Tier Server, com.sas.solutions.risk.irm.fa.&irm_fa_id.));
56%let rmc_fa_path = %sysfunc(metadata_appprop(IRM Mid-Tier Server, com.sas.solutions.risk.irm.fa.&rmc_fa_id.));
57
58/* Set SASAUTOS */
59option insert = (
60 SASAUTOS = (
61 "&irm_fa_path./source/sas/ucmacros"
62 "&rmc_fa_path./source/sas/ucmacros"
63 )
64 );
65
66/* Set logging options (based on the value of LOG_LEVEL macro variable) */
67%irm_set_logging_options();
68
69/* Convert Base date to IRM expected format (MMDDYYYY) */
70%let irm_base_dt = %sysfunc(inputn(&base_dt., yymmdd10.), mmddyyn8.);
71
72/* Set the Cycle directory: the file init.sas will be created in this directory */
73%let cycle_dir = &sas_risk_workgroup_dir./groups/Public/SASRiskManagementCore/cycles/&cycle_id.;
74
75/* Create Cycle directory */
76%rsk_mkdirs_and_verify(&cycle_dir.);
77
78/* Data Repository Libref */
79%let dr_libref = %upcase(&solutionId.)DR;
80/* Data Repository Metadata Library Name */
81%let dr_library_name = SAS &solutionShortName. Data Repository;
82/* Assign Data Repository Library */
83libname &dr_libref. meta liburi = "SASLibrary?@Name='&dr_library_name.'" metaout = data;
84
85/* Reportmart Libref */
86%let mart_libref = %upcase(&solutionLibrefPrefix.)MART;
87/* Reportmart Metadata Library Name */
88%let mart_library_name = SAS &solutionShortName. Reportmart;
89
90/* SAS Risk Management Core Libref */
91%let rmc_libref = RGFRMC;
92/* SAS Risk Management Core Metadata Library Name */
93%let rmc_library_name = SAS Risk Management Core Database;
94
95/* Initialize the Cycle control table */
96%irmc_update_ctrl_table(cycle_id = &cycle_id., dr_libref = &dr_libref.);
97
98/* Get current LUAPATH */
99%let existing_lua = %sysfunc(prxchange(s/[()]//, -1, %sysget(SASLUA)));
100/* Set LUAPATH */
101filename LUAPATH ("&irm_fa_path./source/lua" "&rmc_fa_path./source/lua" &existing_lua.);
102
103/* Get the connection details for the IRM Server */
104%irm_get_service_info(SWCName = IRM Mid-Tier Server
105 , DeployedComponentName = Registered SAS Application
106 , ds_out = irm_info
107 );
108
109/* Load connection details into macro variables */
110data _null_;
111 set irm_info;
112 call symputx("irm_protocol", protocol, "G");
113 call symputx("irm_host", host, "G");
114 call symputx("irm_port", port, "G");
115run;
116
117/* Get the connection details for the VA Server */
118%irm_get_service_info(SWCName = Visual Analytics Transport Service
119 , DeployedComponentName = Registered SAS Application
120 , ds_out = va_info
121 , exact_match = N
122 );
123
124/* Load connection details into macro variables */
125data _null_;
126 set va_info;
127 call symputx("va_protocol", protocol, "G");
128 call symputx("va_host", host, "G");
129 call symputx("va_port", port, "G");
130run;
131
132/* Get the connection details for the RFW Server */
133%irm_get_service_info(SWCName = Risk Financ Wkbnch Mid-Tier
134 , DeployedComponentName = Registered SAS Application
135 , ds_out = rfw_info
136 );
137
138/* Load connection details into macro variables */
139data _null_;
140 set rfw_info;
141 call symputx("rfw_protocol", protocol, "G");
142 call symputx("rfw_host", host, "G");
143 call symputx("rfw_port", port, "G");
144run;
145
146/* Get the connection details for the MIP Server */
147%irm_get_service_info(SWCName = Model Imp Pltfrm Mid-Tier
148 , DeployedComponentName = Registered SAS Application
149 , ds_out = mip_info
150 );
151
152/* Load connection details into macro variables */
153data _null_;
154 set mip_info;
155 call symputx("mip_protocol", protocol, "G");
156 call symputx("mip_host", host, "G");
157 call symputx("mip_port", port, "G");
158 call symputx("mip_service", ksubstr(service, 2), "L");
159run;
160
161/* Get the connection details for Risk Scenario Manager */
162%irm_get_service_info(SWCName = Risk Scenario Manager
163 , DeployedComponentName = Registered SAS Application
164 , ds_out = rsm_info
165 )
166
167/* Load RSM macro variables */
168data _null_;
169 set rsm_info;
170 call symputx("rsm_protocol", protocol, "L");
171 call symputx("rsm_host", host, "L");
172 call symputx("rsm_port", port, "L");
173 call symputx("rsm_service", ksubstr(service, 2), "L");
174run;
175
176/* Set the Java classpath macro variable */
177%irm_get_java_classpath(path = &irm_fa_path./source/java/lib/pdfUtils.jar
178 , outvar = classpath
179 , update_flg = N
180 );
181
182/* Get Entity info from IRM */
183%irm_rest_get_entities(host = &irm_protocol.://&irm_host.
184 , port = &irm_port.
185 , tgt_ticket = &rgf_tgt_ticket.
186 , outds = entities
187 );
188
189/* Get Entity Role Key: (SOLO -> 1, GROUP -> 2) */
190%let entity_role_key =;
191data _null_;
192 set entities (where = (id = "&entity_id." /* and federatedAreaId = "&irm_fa_id." */ and baseDate = "&irm_base_dt."));
193 call symputx("entity_role_key", role_type, "G");
194run;
195/* Abort if we cannot retrieve the entity role */
196%if %sysevalf(%superq(entity_role_key) =, boolean) %then %do;
197 %irm_terminate(msg = Could not retrieve entity role for entity &entity_id. and baseDate &irm_base_dt.);
198%end;
199
200%let content_version =;
201data _null_;
202 length
203 property_name $1000.
204 property_value $1000.
205 ;
206 infile "&irm_fa_path./../version.txt" dlm = ":=";
207 input
208 property_name $
209 property_value $
210 ;
211 if property_name = "Version" then
212 call symputx("content_version", property_value, "G");
213run;
214
215/* Resolve the META libname statement into the actual SASIOLA libname statement */
216%let lasr_libname_stmt =;
217%irm_get_libdebug(libname_stmt = libname rmclasr meta liburi = "SASLibrary?@Name='SAS &solutionShortName. LASR'" metaout = data
218 , outvar = lasr_libname_stmt
219 );
220
221/* Extract the libref from the libname statement */
222%let lasr_libref = %scan(%superq(lasr_libname_stmt), 2, %str( ));
223
224/* ************************************************ */
225/* Start creation of init.sas script file */
226/* ************************************************ */
227data _null_;
228 file "&cycle_dir./init.sas" lrecl = 32000 termstr = nl;
229
230 length str $10000.;
231 str = cat("/* - Cycle Name: &cycle_name.", repeat(" ", %sysfunc(max(1, 45 - %length(%superq(cycle_name))))), "*/");
232
233 put '/****************************************************************/';
234 put '/* Initialization Script */';
235 put "/* - Cycle Id: &cycle_id. */";
236 put str;
237 put "/* - Creation Date: %sysfunc(date(), yymmddd10.) %sysfunc(time(), tod8.) */";
238 put "/* - Analysis Run Id: &analysis_run_id. */";
239 put '/****************************************************************/';
240 put;
241 put '/* Content Version */';
242 put '%let content_version = ' "&content_version.;";
243 put;
244 put '/* Perspective Id */';
245 put '%let perspectiveId = ' "&perspectiveId.;";
246 put;
247 put '/* Solution Id */';
248 put '%let solutionId = ' "&solutionId.;";
249 put;
250 put '/* Solution library prefix */';
251 put '%let solutionLibrefPrefix = ' "&solutionLibrefPrefix.;";
252 put;
253 put '/* Solution Short Name */';
254 put '%let solutionShortName = ' "&solutionShortName.;";
255 put;
256 put '/* Solution Name */';
257 put '%let solutionName = ' "&solutionName.;";
258 put;
259 put '/* Cycle directory */';
260 put '%let cycle_dir = ' "&cycle_dir.;";
261 put;
262 put '/* Solution FA Id */';
263 put '%let irm_fa_id = ' "&irm_fa_id.;";
264 put;
265 put '/* RMC FA Id */';
266 put '%let rmc_fa_id = ' "&rmc_fa_id.;";
267 put;
268 put '/* Metadata Repository */';
269 put '%let meta_repository = Foundation;';
270 put;
271 put "/* &solutionShortName. Data Repository Libref */";
272 put '%let dr_libref = ' "&dr_libref.;";
273 put;
274 put "/* &solutionShortName. Data Repository Metadata Library Name */";
275 put '%let dr_library_name = ' "&dr_library_name.;";
276 put;
277 put "/* &solutionShortName. Reportmart Libref */";
278 put '%let mart_libref = ' "&mart_libref.;";
279 put;
280 put "/* &solutionShortName. Rerportmart Metadata Library Name */";
281 put '%let mart_library_name = ' "&mart_library_name.;";
282 put;
283 put "/* &solutionShortName. LASR Libref */";
284 put '%let lasr_libref = ' "&lasr_libref.;";
285 put;
286 put "/* &solutionShortName. LASR Metadata Library Name */";
287 put '%let lasr_library_name = ' "SAS &solutionShortName. LASR;";
288 put;
289 put '/* Metadata folder for the LASR tables */';
290 put '%let lasr_meta_folder = ' "/Products/&solutionName./Data/Visual Analytics;";
291 put;
292 put '/* Solution FA path */';
293 put '%let irm_fa_path = ' "&irm_fa_path.;";
294 put;
295 put '/* RMC FA path */';
296 put '%let rmc_fa_path = ' "&rmc_fa_path.;";
297 put;
298 put '/* Entity Id */';
299 put '%let entity_id = ' "&entity_id.;";
300 put;
301 put '/* Entity Role Key: 1 -> SOLO, 2 -> GROUP */';
302 put '%let entity_role_key = ' "&entity_role_key.;";
303 put;
304 put '/* Base Date (YYYY-MM-DD) */';
305 put '%let base_dt = ' "&base_dt.;";
306 put;
307 put '/* IRM Base Date (MMDDYYYY) */';
308 put '%let irm_base_dt = ' "&irm_base_dt.;";
309 put;
310 put '/* SAS Risk Workgroup Root directory */';
311 put '%let sas_risk_workgroup_dir = ' "&sas_risk_workgroup_dir.;";
312 put;
313 put '/* RGF Connection parameters */';
314 put '%let rgf_protocol = ' "&rgf_protocol.;";
315 put '%let rgf_host = ' "&rgf_host.;";
316 put '%let rgf_port = ' "&rgf_port.;";
317 put '%let rgf_service = ' "&rgf_service.;";
318 put '%let rgf_solution = ' "&rgf_solution.;";
319 put;
320 put '/* IRM Connection parameters */';
321 put '%let irm_protocol = ' "&irm_protocol.;";
322 put '%let irm_host = ' "&irm_host.;";
323 put '%let irm_port = ' "&irm_port.;";
324 put;
325 put '/* MIP Connection parameters */';
326 put '%let mip_protocol = ' "&mip_protocol.;";
327 put '%let mip_host = ' "&mip_host.;";
328 put '%let mip_port = ' "&mip_port.;";
329 put '%let mip_service = ' "&mip_service.;";
330 put;
331 put '/* RSM Connection parameters */';
332 put '%let rsm_protocol = ' "&rsm_protocol.;";
333 put '%let rsm_host = ' "&rsm_host.;";
334 put '%let rsm_port = ' "&rsm_port.;";
335 put '%let rsm_service = ' "&rsm_service.;";
336 put;
337 put '/* VA Connection parameters */';
338 put '%let va_protocol = ' "&va_protocol.;";
339 put '%let va_host = ' "&va_host.;";
340 put '%let va_port = ' "&va_port.;";
341 put;
342 put '/* Set SASAUTOS and Java CLASSPATH */';
343 put 'options ';
344 put ' insert = (sasautos = (';
345 put " ""&irm_fa_path./source/sas/ucmacros""";
346 put " ""&rmc_fa_path./source/sas/ucmacros""";
347 put ' )';
348 put ' )';
349 put " set = CLASSPATH ""&classpath.""";
350 put ';';
351 put;
352 put 'options ibufsize = 32760;';
353 put;
354 put '/* Set compress option */';
355 put 'options compress = binary;';
356 put;
357 put '/* Enable direct execution of sql statement using database engine (for DB libraries) */';
358 put 'options dbidirectexec;';
359 put;
360 put '/* Set LUAPATH */';
361 put "filename LUAPATH (""&irm_fa_path./source/lua""";
362 put " ""&rmc_fa_path./source/lua""";
363 put " %sysfunc(prxchange(s/[""]/""/i, -1, &existing_lua.))";
364 put ' );';
365 put;
366 put "/* &solutionShortName. Data Repository */";
367 put "libname &dr_libref. meta liburi = ""SASLibrary?@Name='&dr_library_name.'"" metaout = data;";
368 put;
369 put "/* &solutionShortName. Reportmart */";
370 put "libname &mart_libref. meta liburi = ""SASLibrary?@Name='&mart_library_name.'"" metaout = data;";
371 put;
372 put "/* &solutionShortName. LASR */";
373 put "%sysfunc(prxchange(s/[""]/""/i, -1, %superq(lasr_libname_stmt)))";
374 put;
375 put "/* SAS Risk Management Core Database */";
376 put "libname &rmc_libref. meta liburi = ""SASLibrary?@Name='&rmc_library_name.'"" metaout = data;";
377
378run;