SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmst_node_filter_entity.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 Filter Entity Hierarchy
7
8 \param[in] entity_id Entity Identifier
9 \param[in] group_flg Group Flag (Y/N). See below for details
10 \param[in] ds_in_entity Input Entity table
11 \param[out] ds_out_entity Output Entity table
12
13 \details
14
15 This node filters the input Entity table according to the following logic:
16 - If <i>GROUP_FLG</i> = N then only the specified <i>&ENTITY_ID</i> is retrieved
17 - If <i>GROUP_FLG</i> = Y then the specified <i>&ENTITY_ID</i> and related children entities are retrieved
18
19 In addition the following macro utilities are called:
20
21 | Macro name | Description | Further information |
22 |---------------------------|--------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
23 | irm_session_prepare | Reads RUN_OPTION table and sets logging options | \link irm_session_prepare.sas \endlink |
24 | 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 |
25
26 \ingroup nodes
27 \author SAS Institute Inc.
28 \date 2018
29*/
30
31/* Initialize session */
32%irm_session_prepare();
33
34data &ds_out_entity.;
35 set &ds_in_entity.;
36 length
37 _tmp_entity_id $32.
38 _tmp_group_id $32.
39 ;
40 drop _tmp_:;
41
42 %if(&group_flg. = Y) %then %do;
43 if _N_ = 1 then do;
44 /* Declare lookup table */
45 declare hash hEntity(dataset: "&ds_in_entity.(keep = entity_id group_id rename = (entity_id = _tmp_entity_id group_id = _tmp_group_id))");
46 hEntity.defineKey("_tmp_entity_id");
47 hEntity.defineData("_tmp_group_id");
48 hEntity.defineDone();
49 end;
50 %end;
51
52 if(entity_id = "&entity_id.") then
53 output;
54 %if(&group_flg. = Y) %then %do;
55 else do;
56 _tmp_entity_id = entity_id;
57 /* Traverse the entity hierarchy to get all parent entities */
58 do while(hEntity.find() = 0);
59 /* Check if the parent is the required &entity_id */
60 if(_tmp_group_id = "&entity_id.") then
61 output;
62 /* Update the key for the next lookup */
63 _tmp_entity_id = _tmp_group_id;
64 end;
65 end;
66 %end;
67
68run;
69
70/* Cleanup session */
71%irm_session_cleanup;