SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmst_node_init.sas
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 SAS Institute Inc. Cary, NC, USA
3*/
4
5/** \file
6 \brief Initialize jobflow parameters
7
8 \details
9
10 This node performs the following tasks:
11 - Get REST service information for interacting with SAS Risk Governance Framework (see macro \link irm_get_service_info.sas \endlink for details)
12 - Prepare parameter table for downstream processing
13
14
15 In addition the following macro utilities are called:
16
17 | Macro name | Description | Further information |
18 |---------------------------|--------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
19 | irm_session_prepare | Reads RUN_OPTION table and sets logging options | \link irm_session_prepare.sas \endlink |
20 | irm_session_cleanup | Removes all non-IRM WORK datasets/views and deletes all user-created macro variables from workspace session | \link irm_session_cleanup.sas \endlink |
21
22 \ingroup nodes
23 \author SAS Institute Inc.
24 \date 2018
25*/
26
27/* Initialize session */
28%irm_session_prepare();
29
30/* ************************************************************* */
31/* Step 1: Get Rest service infos */
32/* ************************************************************* */
33
34/* Set metadata credentials */
35%irm_set_meta_connection(IRM_GENERATED_PW_MACVAR = IRM_USER_PASSWORD_1);
36
37/* Get the connection details for the RGF Server */
38%irm_get_service_info(SWCName = Risk Gov Frwk Mid-Tier
39 , DeployedComponentName = Registered SAS Application
40 , ds_out = rgf_info
41 );
42
43/* Load connection details into macro variables */
44data _null_;
45 set rgf_info;
46 call symputx("rgf_protocol", protocol, "G");
47 call symputx("rgf_host", host, "G");
48 call symputx("rgf_port", port, "G");
49 call symputx("rgf_service", ksubstr(service, 2), "G");
50run;
51
52/* Set metadata credentials */
53%irm_set_meta_connection(IRM_GENERATED_PW_MACVAR = IRM_USER_PASSWORD_2);
54
55/* Get the connection details for the RSM Server */
56%irm_get_service_info(SWCName = Risk Scenario Manager
57 , DeployedComponentName = Registered SAS Application
58 , ds_out = rsm_info
59 );
60
61/* Load connection details into macro variables */
62data _null_;
63 set rsm_info;
64 call symputx("rsm_protocol", protocol, "G");
65 call symputx("rsm_host", host, "G");
66 call symputx("rsm_port", port, "G");
67 call symputx("rsm_service", ksubstr(service, 2), "G");
68run;
69
70/* Set metadata credentials */
71%irm_set_meta_connection(IRM_GENERATED_PW_MACVAR = IRM_USER_PASSWORD_3);
72
73/* Get the connection details for the MIP Server */
74%irm_get_service_info(SWCName = Model Imp Pltfrm Mid-Tier
75 , DeployedComponentName = Registered SAS Application
76 , ds_out = mip_info
77 );
78
79/* Load connection details into macro variables */
80data _null_;
81 set mip_info;
82 call symputx("mip_protocol", protocol, "G");
83 call symputx("mip_host", host, "G");
84 call symputx("mip_port", port, "G");
85 call symputx("mip_service", ksubstr(service, 2), "G");
86run;
87
88/* Set metadata credentials */
89%irm_set_meta_connection(IRM_GENERATED_PW_MACVAR = IRM_USER_PASSWORD_4);
90
91/* Get SAS Risk Workgroup root directory */
92%let sas_risk_workgroup_dir = %sysfunc(metadata_appprop(Risk Work Group Svr Cfg, root.dir));
93
94
95/* ****************************************************************** */
96/* Step 2: Retrieve Cycle information */
97/* ****************************************************************** */
98
99%let ticket =;
100%let httpSuccess = 0;
101%let responseStatus =;
102%irm_rest_get_rgf_cycle(host = &rgf_protocol.://&rgf_host.
103 , server = &rgf_service.
104 , solution = &rgf_solution.
105 , port = &rgf_port.
106 , tgt_ticket = &tgt_ticket.
107 , username = &irm_user_id.
108 , password = &irm_user_password_5.
109 , key = &cycle_id.
110 , outds = cycle_info
111 , outVarTicket = ticket
112 , outSuccess = httpSuccess
113 , outResponseStatus = responseStatus
114 );
115
116
117/* ****************************************************************** */
118/* Step 2: Retrieve Analysis Run information */
119/* ****************************************************************** */
120
121%let httpSuccess = 0;
122%let responseStatus =;
123%irm_rest_get_rgf_analysis_run(host = &rgf_protocol.://&rgf_host.
124 , server = &rgf_service.
125 , solution = &rgf_solution.
126 , port = &rgf_port.
127 , tgt_ticket = &tgt_ticket.
128 , username = &irm_user_id.
129 , password = &irm_user_password_6.
130 , key = &analysis_run_id.
131 , outds = analysis_run
132 , outds_params = analysis_run_params
133 , fout_code =
134 , outVarTicket = ticket
135 , outSuccess = httpSuccess
136 , outResponseStatus = responseStatus
137 );
138
139/* Get the Analysis Run attributes (name and production flag) */
140data _null_;
141 set analysis_run;
142 call symputx("analysis_run_name", name, "G");
143 call symputx("analysis_run_type", ifc(prodRunFlg = "true", "Production", "What-If"), "G");
144run;
145
146/* Set metadata credentials */
147%irm_set_meta_connection(IRM_GENERATED_PW_MACVAR = IRM_USER_PASSWORD_7);
148
149%let fa_id =;
150%let content_version =;
151data _null_;
152 length
153 str $1000.
154 version_fpath $4000.
155 content_version $100.
156 ;
157
158 set cycle_info;
159
160 /* Get the path to the requested IRM federated area */
161 fa_path = metadata_appprop("IRM Mid-Tier Server",cats("com.sas.solutions.risk.irm.fa.", versionNm));
162 version_fpath = catx("/../", fa_path, "version.txt");
163 /* Set the filename to the version.txt file (one directory level up from the IRM fa location) */
164 rc = filename("fref", version_fpath);
165 if rc = 0 then do;
166 /* Open the version.txt file */
167 fid = fopen("fref");
168 if fid > 0 then do;
169 rc = fsep(fid, '#');
170 found = 0;
171 rc_fread = 0;
172 /* Loop through all records */
173 do while(found = 0 and rc_fread = 0);
174 /* Read a record to the file data buffer */
175 rc_fread = fread(fid);
176 if(rc_fread = 0) then do;
177 /* Copy the content of the file data buffer to the STR variable */
178 rc = fget(fid, str);
179 /* Check if this record starts with "Version:" or "Version=" */
180 if prxmatch("/^Version:/i", str) then do;
181 found = 1;
182 /* Get the content version */
183 content_version = prxchange("s/^Version:\s*//i", -1, str);
184 end;
185 else if prxmatch("/^Version=/i", str) then do;
186 found = 1;
187 /* Get the content version */
188 content_version = prxchange("s/^Version=\s*//i", -1, str);
189 end;
190 end; /* if(rc_fread = 0) */
191 end; /* Loop through all records */
192 end; /* if fid > 0 */
193 else do;
194 put "WARNING: Could not open file " version_fpath;
195 end;
196 end; /* if rc = 0 */
197 else do;
198 put "WARNING: Could not assign a filename to " version_fpath;
199 end;
200
201 /* Set macro variables */
202 call symputx("fa_id", versionNm, "G");
203 call symputx("fa_path", fa_path, "G");
204 call symputx("content_version", content_version, "G");
205 call symputx("cycle_name", name, "G");
206run;
207
208/* Process the libnames.txt to retrieve the list of input/generic librefs */
209data _null_;
210 infile "&fa_path./config/libnames.txt" lrecl = 32000 end = last;
211 length irm_input_libraries $10000.;
212 retain irm_input_libraries;
213 retain rx;
214
215 input;
216
217 /* Compile regular expression to extract the libref */
218 if _N_ = 1 then
219 rx = prxparse("s/(LIBREF\s+)?(\w+)=.*/$2/i");
220
221 if(prxmatch(rx, _infile_)) then
222 irm_input_libraries = catx(" ", irm_input_libraries, prxchange(rx, -1, _infile_));
223
224 if last then
225 call symputx("irm_input_libraries", irm_input_libraries, "G");;
226run;
227
228/* ****************************************************************** */
229/* Step 3: Prepare Parameter table for downstream processing */
230/* ****************************************************************** */
231
232data &ds_out_run_option.;
233 set
234 &ds_in_run_option.
235 &ds_in_system_option. end = last
236 ;
237 output;
238 if last then do;
239 config_name = "RGF_PROTOCOL"; config_value = "&rgf_protocol."; config_value_desc = "SAS Risk Governamce Framework connection protocol"; output;
240 config_name = "RGF_HOST"; config_value = "&rgf_host."; config_value_desc = "SAS Risk Governamce Framework connection host"; output;
241 config_name = "RGF_PORT"; config_value = "&rgf_port."; config_value_desc = "SAS Risk Governamce Framework connection port"; output;
242 config_name = "RGF_SERVICE"; config_value = "&rgf_service."; config_value_desc = "SAS Risk Governamce Framework connection service"; output;
243 config_name = "RSM_PROTOCOL"; config_value = "&rsm_protocol."; config_value_desc = "SAS Risk Scenario Manager connection protocol"; output;
244 config_name = "RSM_HOST"; config_value = "&rsm_host."; config_value_desc = "SAS Risk Scenario Manager connection host"; output;
245 config_name = "RSM_PORT"; config_value = "&rsm_port."; config_value_desc = "SAS Risk Scenario Manager connection port"; output;
246 config_name = "RSM_SERVICE"; config_value = "&rsm_service."; config_value_desc = "SAS Risk Scenario Manager connection service"; output;
247 config_name = "MIP_PROTOCOL"; config_value = "&mip_protocol."; config_value_desc = "SAS Model Implementation Platform connection protocol"; output;
248 config_name = "MIP_HOST"; config_value = "&mip_host."; config_value_desc = "SAS Model Implementation Platform connection host"; output;
249 config_name = "MIP_PORT"; config_value = "&mip_port."; config_value_desc = "SAS Model Implementation Platform connection port"; output;
250 config_name = "MIP_SERVICE"; config_value = "&mip_service."; config_value_desc = "SAS Model Implementation Platform connection service"; output;
251 config_name = "SAS_RISK_WORKGROUP_DIR"; config_value = "&sas_risk_workgroup_dir."; config_value_desc = "SAS Risk Workgroup root directory"; output;
252 config_name = "FA_ID"; config_value = "&fa_id."; config_value_desc = "Federated Area Id"; output;
253 config_name = "FA_PATH"; config_value = "&fa_path."; config_value_desc = "Federated Area Path"; output;
254 config_name = "CONTENT_VERSION"; config_value = "&content_version."; config_value_desc = "Content Version"; output;
255 config_name = "CYCLE_NAME"; config_value = "&cycle_name."; config_value_desc = "Cycle Name"; output;
256 config_name = "ANALYSIS_RUN_NAME"; config_value = "&analysis_run_name."; config_value_desc = "Analysis Run Name"; output;
257 config_name = "ANALYSIS_RUN_TYPE"; config_value = "&analysis_run_type."; config_value_desc = "Analysis Run Type: Production/What-If"; output;
258 config_name = "IRM_INPUT_LIBRARIES"; config_value = "&irm_input_libraries."; config_value_desc = "List of IRM input/generic libraries"; output;
259 end;
260run;
261
262/* Cleanup session */
263%irm_session_cleanup;