@sasjs/core 3.6.0 → 3.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/mp_coretable.sas +92 -0
- package/base/mp_filterstore.sas +230 -0
- package/base/mp_getcols.sas +18 -16
- package/base/mp_lockanytable.sas +2 -13
- package/base/mp_retainedkey.sas +18 -20
- package/package.json +2 -2
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Create the permanent Core tables
|
|
4
|
+
@details Several macros in the [core](https://github.com/sasjs/core) library
|
|
5
|
+
make use of permanent tables. To avoid duplication in definitions, this
|
|
6
|
+
macro provides a central location for managing the corresponding DDL.
|
|
7
|
+
|
|
8
|
+
Example usage:
|
|
9
|
+
|
|
10
|
+
%mp_coretable(LOCKTABLE,libds=work.locktable)
|
|
11
|
+
|
|
12
|
+
@param [in] table_ref The type of table to create. Example values:
|
|
13
|
+
@li FILTER_DETAIL - For storing detailed filter values. Used by
|
|
14
|
+
mp_filterstore.sas.
|
|
15
|
+
@li FILTER_SUMMARY - For storing summary filter values. Used by
|
|
16
|
+
mp_filterstore.sas.
|
|
17
|
+
@li LOCKANYTABLE - For "locking" tables prior to multipass loads. Used by
|
|
18
|
+
mp_lockanytable.sas
|
|
19
|
+
@li MAXKEYTABLE - For storing the maximum retained key information. Used
|
|
20
|
+
by mp_retainedkey.sas
|
|
21
|
+
@param [in] libds= (0) The library.dataset reference used to create the table.
|
|
22
|
+
If not provided, then the DDL is simply printed to the log.
|
|
23
|
+
|
|
24
|
+
<h4> Related Macros </h4>
|
|
25
|
+
@li mp_filterstore.sas
|
|
26
|
+
@li mp_lockanytable.sas
|
|
27
|
+
@li mp_retainedkey.sas
|
|
28
|
+
|
|
29
|
+
@version 9.2
|
|
30
|
+
@author Allan Bowe
|
|
31
|
+
|
|
32
|
+
**/
|
|
33
|
+
|
|
34
|
+
%macro mp_coretable(table_ref,libds=0
|
|
35
|
+
)/*/STORE SOURCE*/;
|
|
36
|
+
%local outds ;
|
|
37
|
+
%let outds=%sysfunc(ifc(&libds=0,_data_,&libds));
|
|
38
|
+
proc sql;
|
|
39
|
+
%if &table_ref=LOCKTABLE %then %do;
|
|
40
|
+
create table &outds(
|
|
41
|
+
lock_lib char(8),
|
|
42
|
+
lock_ds char(32),
|
|
43
|
+
lock_status_cd char(10) not null,
|
|
44
|
+
lock_user_nm char(100) not null ,
|
|
45
|
+
lock_ref char(200),
|
|
46
|
+
lock_pid char(10),
|
|
47
|
+
lock_start_dttm num format=E8601DT26.6,
|
|
48
|
+
lock_end_dttm num format=E8601DT26.6,
|
|
49
|
+
constraint pk_mp_lockanytable primary key(lock_lib,lock_ds));
|
|
50
|
+
%end;
|
|
51
|
+
%else %if &table_ref=FILTER_SUMMARY %then %do;
|
|
52
|
+
create table &outds(
|
|
53
|
+
filter_rk num not null,
|
|
54
|
+
filter_hash char(32) not null,
|
|
55
|
+
filter_table char(41) not null,
|
|
56
|
+
processed_dttm num not null format=E8601DT26.6,
|
|
57
|
+
constraint pk_mpe_filteranytable
|
|
58
|
+
primary key(filter_rk));
|
|
59
|
+
%end;
|
|
60
|
+
%else %if &table_ref=FILTER_DETAIL %then %do;
|
|
61
|
+
create table &outds(
|
|
62
|
+
filter_hash char(32) not null,
|
|
63
|
+
filter_line num not null,
|
|
64
|
+
group_logic char(3) not null,
|
|
65
|
+
subgroup_logic char(3) not null,
|
|
66
|
+
subgroup_id num not null,
|
|
67
|
+
variable_nm varchar(32) not null,
|
|
68
|
+
operator_nm varchar(12) not null,
|
|
69
|
+
raw_value varchar(4000) not null,
|
|
70
|
+
processed_dttm num not null format=E8601DT26.6,
|
|
71
|
+
constraint pk_mpe_filteranytable
|
|
72
|
+
primary key(filter_hash,filter_line));
|
|
73
|
+
%end;
|
|
74
|
+
%else %if &table_ref=MAXKEYTABLE %then %do;
|
|
75
|
+
create table &outds(
|
|
76
|
+
keytable varchar(41) label='Base table in libref.dataset format',
|
|
77
|
+
keycolumn char(32) format=$32.
|
|
78
|
+
label='The Retained key field containing the key values.',
|
|
79
|
+
max_key num label=
|
|
80
|
+
'Integer representing current max RK or SK value in the KEYTABLE',
|
|
81
|
+
processed_dttm num format=E8601DT26.6
|
|
82
|
+
label='Datetime this value was last updated',
|
|
83
|
+
constraint pk_mpe_maxkeyvalues
|
|
84
|
+
primary key(keytable));
|
|
85
|
+
%end;
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
%if &libds=0 %then %do;
|
|
89
|
+
describe table &syslast;
|
|
90
|
+
drop table &syslast;
|
|
91
|
+
%end;
|
|
92
|
+
%mend mp_coretable;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Checks & Stores an input filter table and returns the Filter Key
|
|
4
|
+
@details Used to generate a FILTER_RK from an input query dataset. This
|
|
5
|
+
process requires several permanent tables (names are configurable). The
|
|
6
|
+
benefit of storing query values at backend is to enable stored 'views' of
|
|
7
|
+
filtered tables at frontend (ie, when building [SAS-Powered Apps](
|
|
8
|
+
https://sasapps.io)). This macro is also used in [Data Controller for SAS](
|
|
9
|
+
https://datacontroller.io).
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@param [in] libds= The target dataset to be filtered (lib should be assigned)
|
|
13
|
+
@param [in] queryds= (WORK.FILTERQUERY) The temporary input query dataset to
|
|
14
|
+
be validated. Has the following format:
|
|
15
|
+
|GROUP_LOGIC:$3|SUBGROUP_LOGIC:$3|SUBGROUP_ID:8.|VARIABLE_NM:$32|OPERATOR_NM:$10|RAW_VALUE:$32767|
|
|
16
|
+
|---|---|---|---|---|---|
|
|
17
|
+
|AND|AND|1|SOME_BESTNUM|>|1|
|
|
18
|
+
|AND|AND|1|SOME_TIME|=|77333|
|
|
19
|
+
@param [in] filter_summary= (PERM.FILTER_SUMMARY) Permanent table containing
|
|
20
|
+
summary filter values. The definition is available by running
|
|
21
|
+
mp_coretable.sas as follows: `mp_coretable(FILTER_SUMMARY)`. Example
|
|
22
|
+
values:
|
|
23
|
+
|FILTER_RK:best.|FILTER_HASH:$32.|FILTER_TABLE:$41.|PROCESSED_DTTM:datetime19.|
|
|
24
|
+
|---|---|---|---|
|
|
25
|
+
|`1 `|`540E96F566D194AB58DD4C413C99C9DB `|`VIYA6014.MPE_TABLES `|`1956084246 `|
|
|
26
|
+
|`2 `|`87737DB9EEE2650F5C89956CEAD0A14F `|`VIYA6014.MPE_X_TEST `|`1956084452.1`|
|
|
27
|
+
|`3 `|`8048BD908DBBD83D013560734E90D394 `|`VIYA6014.MPE_TABLES `|`1956093620.6`|
|
|
28
|
+
@param [in] filter_detail= (PERM.FILTER_DETAIL) Permanent table containing
|
|
29
|
+
detailed (raw) filter values. The definition is available by running
|
|
30
|
+
mp_coretable.sas as follows: `mp_coretable(FILTER_DETAIL)`. Example
|
|
31
|
+
values:
|
|
32
|
+
|FILTER_HASH:$32.|FILTER_LINE:best.|GROUP_LOGIC:$3.|SUBGROUP_LOGIC:$3.|SUBGROUP_ID:best.|VARIABLE_NM:$32.|OPERATOR_NM:$12.|RAW_VALUE:$4000.|PROCESSED_DTTM:datetime19.|
|
|
33
|
+
|---|---|---|---|---|---|---|---|---|
|
|
34
|
+
|`540E96F566D194AB58DD4C413C99C9DB `|`1 `|`AND `|`AND `|`1 `|`LIBREF `|`CONTAINS `|`DC`|`1956084245.8 `|
|
|
35
|
+
|`540E96F566D194AB58DD4C413C99C9DB `|`2 `|`AND `|`OR `|`2 `|`DSN `|`= `|` MPE_LOCK_ANYTABLE `|`1956084245.8 `|
|
|
36
|
+
|`87737DB9EEE2650F5C89956CEAD0A14F `|`1 `|`AND `|`AND `|`1 `|`PRIMARY_KEY_FIELD `|`IN `|`(1,2,3) `|`1956084451.9 `|
|
|
37
|
+
@param [in] lock_table= (PERM.LOCK_TABLE) Permanent locking table. Used to
|
|
38
|
+
manage concurrent access. The definition is available by running
|
|
39
|
+
mp_coretable.sas as follows: `mp_coretable(LOCKTABLE)`.
|
|
40
|
+
@param [in] maxkeytable= (0) Optional permanent reference table used for
|
|
41
|
+
retained key tracking. Described in mp_retainedkey.sas.
|
|
42
|
+
@param [in] mdebug= set to 1 to enable DEBUG messages
|
|
43
|
+
@param [out] outresult= The result table with the FILTER_RK
|
|
44
|
+
@param [out] outquery= The original query, taken as extract after table load
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
<h4> SAS Macros </h4>
|
|
48
|
+
@li mf_getuniquename.sas
|
|
49
|
+
@li mf_getvalue.sas
|
|
50
|
+
@li mf_islibds.sas
|
|
51
|
+
@li mf_nobs.sas
|
|
52
|
+
@li mp_abort.sas
|
|
53
|
+
@li mp_filtercheck.sas
|
|
54
|
+
@li mp_hashdataset.sas
|
|
55
|
+
@li mp_retainedkey.sas
|
|
56
|
+
|
|
57
|
+
<h4> Related Macros </h4>
|
|
58
|
+
@li mp_filtercheck.sas
|
|
59
|
+
@li mp_filtergenerate.sas
|
|
60
|
+
@li mp_filtervalidate.sas
|
|
61
|
+
@li mp_filterstore.test.sas
|
|
62
|
+
|
|
63
|
+
@version 9.2
|
|
64
|
+
@author [Allan Bowe](https://www.linkedin.com/in/allanbowe)
|
|
65
|
+
|
|
66
|
+
**/
|
|
67
|
+
|
|
68
|
+
%macro mp_filterstore(libds=,
|
|
69
|
+
queryds=work.filterquery,
|
|
70
|
+
filter_summary=PERM.FILTER_SUMMARY,
|
|
71
|
+
filter_detail=PERM.FILTER_DETAIL,
|
|
72
|
+
lock_table=PERM.LOCK_TABLE,
|
|
73
|
+
maxkeytable=PERM.MAXKEYTABLE,
|
|
74
|
+
outresult=work.result,
|
|
75
|
+
outquery=work.query,
|
|
76
|
+
mdebug=1
|
|
77
|
+
);
|
|
78
|
+
%put &sysmacroname entry vars:;
|
|
79
|
+
%put _local_;
|
|
80
|
+
|
|
81
|
+
%local ds1 ds2 ds3 ds4 filter_hash;
|
|
82
|
+
%mp_abort(iftrue= (&syscc ne 0)
|
|
83
|
+
,mac=mp_filterstore
|
|
84
|
+
,msg=%str(syscc=&syscc on macro entry)
|
|
85
|
+
)
|
|
86
|
+
%mp_abort(iftrue= (%mf_islibds(&filter_summary)=0)
|
|
87
|
+
,mac=mp_filterstore
|
|
88
|
+
,msg=%str(Invalid filter_summary value: &filter_summary)
|
|
89
|
+
)
|
|
90
|
+
%mp_abort(iftrue= (%mf_islibds(&filter_detail)=0)
|
|
91
|
+
,mac=mp_filterstore
|
|
92
|
+
,msg=%str(Invalid filter_detail value: &filter_detail)
|
|
93
|
+
)
|
|
94
|
+
%mp_abort(iftrue= (%mf_islibds(&lock_table)=0)
|
|
95
|
+
,mac=mp_filterstore
|
|
96
|
+
,msg=%str(Invalid lock_table value: &lock_table)
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
/* validate query */
|
|
100
|
+
%mp_filtercheck(&queryds,targetds=&libds,abort=YES)
|
|
101
|
+
|
|
102
|
+
/* hash the result */
|
|
103
|
+
%let ds1=%mf_getuniquename(prefix=hashds);
|
|
104
|
+
%mp_hashdataset(&queryds,outds=&ds1,salt=&libds)
|
|
105
|
+
%let filter_hash=%upcase(%mf_getvalue(&ds1,hashkey));
|
|
106
|
+
%if &mdebug=1 %then %do;
|
|
107
|
+
data _null_;
|
|
108
|
+
putlog "filter_hash=&filter_hash";
|
|
109
|
+
set &ds1;
|
|
110
|
+
putlog (_all_)(=);
|
|
111
|
+
run;
|
|
112
|
+
%end;
|
|
113
|
+
|
|
114
|
+
/* check if data already exists for this hash */
|
|
115
|
+
data &outresult;
|
|
116
|
+
set &filter_summary;
|
|
117
|
+
where filter_hash="&filter_hash";
|
|
118
|
+
run;
|
|
119
|
+
|
|
120
|
+
%mp_abort(iftrue= (&syscc ne 0)
|
|
121
|
+
,mac=mp_filterstore
|
|
122
|
+
,msg=%str(syscc=&syscc after hash check)
|
|
123
|
+
)
|
|
124
|
+
%mp_abort(iftrue= ("&filter_hash "=" ")
|
|
125
|
+
,mac=mp_filterstore
|
|
126
|
+
,msg=%str(problem with filter_hash generation)
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
%if %mf_nobs(&outresult)=0 %then %do;
|
|
130
|
+
|
|
131
|
+
/* first update summary table */
|
|
132
|
+
%let ds3=%mf_getuniquename(prefix=filtersum);
|
|
133
|
+
data work.&ds3;
|
|
134
|
+
if 0 then set &filter_summary;
|
|
135
|
+
filter_table=symget('libds');
|
|
136
|
+
filter_hash="&filter_hash";
|
|
137
|
+
PROCESSED_DTTM=%sysfunc(datetime());
|
|
138
|
+
output;
|
|
139
|
+
stop;
|
|
140
|
+
run;
|
|
141
|
+
|
|
142
|
+
%mp_lockanytable(LOCK,
|
|
143
|
+
lib=%scan(&filter_summary,1,.)
|
|
144
|
+
,ds=%scan(&filter_summary,2,.)
|
|
145
|
+
,ref=MP_FILTERSTORE summary update - &filter_hash
|
|
146
|
+
,ctl_ds=&lock_table
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
%let ds4=%mf_getuniquename(prefix=filtersumappend);
|
|
150
|
+
%mp_retainedkey(
|
|
151
|
+
base_lib=%scan(&filter_summary,1,.)
|
|
152
|
+
,base_dsn=%scan(&filter_summary,2,.)
|
|
153
|
+
,append_lib=work
|
|
154
|
+
,append_dsn=&ds3
|
|
155
|
+
,retained_key=filter_rk
|
|
156
|
+
,business_key=filter_hash
|
|
157
|
+
,maxkeytable=&maxkeytable
|
|
158
|
+
,locktable=&lock_table
|
|
159
|
+
,outds=work.&ds4
|
|
160
|
+
)
|
|
161
|
+
proc append base=&filter_summary data=&ds4;
|
|
162
|
+
run;
|
|
163
|
+
|
|
164
|
+
%mp_lockanytable(UNLOCK,
|
|
165
|
+
lib=%scan(&filter_summary,1,.)
|
|
166
|
+
,ds=%scan(&filter_summary,2,.)
|
|
167
|
+
,ref=MP_FILTERSTORE summary update - &filter_hash
|
|
168
|
+
,ctl_ds=&lock_table
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
%if &syscc ne 0 %then %do;
|
|
172
|
+
data _null_;
|
|
173
|
+
set &ds4;
|
|
174
|
+
putlog (_all_)(=);
|
|
175
|
+
run;
|
|
176
|
+
%goto err;
|
|
177
|
+
%end;
|
|
178
|
+
|
|
179
|
+
data &outresult;
|
|
180
|
+
set &filter_summary;
|
|
181
|
+
where filter_hash="&filter_hash";
|
|
182
|
+
run;
|
|
183
|
+
|
|
184
|
+
/* Next, update detail table */
|
|
185
|
+
%let ds2=%mf_getuniquename(prefix=filterdetail);
|
|
186
|
+
data &ds2;
|
|
187
|
+
if 0 then set &filter_detail;
|
|
188
|
+
set &queryds;
|
|
189
|
+
format filter_hash $hex32. filter_line 8.;
|
|
190
|
+
filter_hash="&filter_hash";
|
|
191
|
+
filter_line=_n_;
|
|
192
|
+
PROCESSED_DTTM=%sysfunc(datetime());
|
|
193
|
+
run;
|
|
194
|
+
%mp_lockanytable(LOCK,
|
|
195
|
+
lib=%scan(&filter_detail,1,.)
|
|
196
|
+
,ds=%scan(&filter_detail,2,.)
|
|
197
|
+
,ref=MP_FILTERSTORE update - &filter_hash
|
|
198
|
+
,ctl_ds=&lock_table
|
|
199
|
+
)
|
|
200
|
+
proc append base=&filter_detail data=&ds2;
|
|
201
|
+
run;
|
|
202
|
+
|
|
203
|
+
%mp_lockanytable(UNLOCK,
|
|
204
|
+
lib=%scan(&filter_detail,1,.)
|
|
205
|
+
,ds=%scan(&filter_detail,2,.)
|
|
206
|
+
,ref=MP_FILTERSTORE detail update &filter_hash
|
|
207
|
+
,ctl_ds=&lock_table
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
%if &syscc ne 0 %then %do;
|
|
211
|
+
data _null_;
|
|
212
|
+
set &ds2;
|
|
213
|
+
putlog (_all_)(=);
|
|
214
|
+
run;
|
|
215
|
+
%goto err;
|
|
216
|
+
%end;
|
|
217
|
+
|
|
218
|
+
%end;
|
|
219
|
+
|
|
220
|
+
proc sort data=&filter_detail(where=(filter_hash="&filter_hash")) out=&outquery;
|
|
221
|
+
by filter_line;
|
|
222
|
+
run;
|
|
223
|
+
|
|
224
|
+
%err:
|
|
225
|
+
%mp_abort(iftrue= (&syscc ne 0)
|
|
226
|
+
,mac=mp_filterstore
|
|
227
|
+
,msg=%str(syscc=&syscc on macro exit)
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
%mend mp_filterstore;
|
package/base/mp_getcols.sas
CHANGED
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
|
|
15
15
|
@param ds The dataset from which to obtain column metadata
|
|
16
16
|
@param outds= (work.cols) The output dataset to create. Sample data:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
|NAME:$32.|LENGTH:best.|VARNUM:best.|LABEL:$256.|FMTNAME:$32.|FORMAT:$49.|TYPE:$1.|DDTYPE:$9.|
|
|
18
|
+
|---|---|---|---|---|---|---|---|
|
|
19
|
+
|`AIR `|`8 `|`2 `|`international airline travel (thousands) `|` `|`8. `|`N `|`NUMERIC `|
|
|
20
|
+
|`DATE `|`8 `|`1 `|`DATE `|`MONYY `|`MONYY. `|`N `|`DATE `|
|
|
21
|
+
|`REGION `|`3 `|`3 `|`REGION `|` `|`$3. `|`C `|`CHARACTER `|
|
|
22
22
|
|
|
23
23
|
<h4> Related Macros </h4>
|
|
24
24
|
@li mf_getvarlist.sas
|
|
@@ -30,26 +30,27 @@
|
|
|
30
30
|
**/
|
|
31
31
|
|
|
32
32
|
%macro mp_getcols(ds, outds=work.cols);
|
|
33
|
-
|
|
33
|
+
%local dropds;
|
|
34
34
|
proc contents noprint data=&ds
|
|
35
35
|
out=_data_ (keep=name type length label varnum format:);
|
|
36
36
|
run;
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
%let dropds=&syslast;
|
|
38
|
+
data &outds(keep=name type length varnum format label ddtype fmtname);
|
|
39
|
+
set &dropds(rename=(format=fmtname type=type2));
|
|
39
40
|
name=upcase(name);
|
|
40
41
|
if type2=2 then do;
|
|
41
42
|
length format $49.;
|
|
42
|
-
if
|
|
43
|
-
else if formatl=0 then format=cats(
|
|
44
|
-
else format=cats(
|
|
43
|
+
if fmtname='' then format=cats('$',length,'.');
|
|
44
|
+
else if formatl=0 then format=cats(fmtname,'.');
|
|
45
|
+
else format=cats(fmtname,formatl,'.');
|
|
45
46
|
type='C';
|
|
46
47
|
ddtype='CHARACTER';
|
|
47
48
|
end;
|
|
48
49
|
else do;
|
|
49
|
-
if
|
|
50
|
-
else if formatl=0 then format=cats(
|
|
51
|
-
else if formatd=0 then format=cats(
|
|
52
|
-
else format=cats(
|
|
50
|
+
if fmtname='' then format=cats(length,'.');
|
|
51
|
+
else if formatl=0 then format=cats(fmtname,'.');
|
|
52
|
+
else if formatd=0 then format=cats(fmtname,formatl,'.');
|
|
53
|
+
else format=cats(fmtname,formatl,'.',formatd);
|
|
53
54
|
type='N';
|
|
54
55
|
if format=:'DATETIME' or format=:'E8601DT' then ddtype='DATETIME';
|
|
55
56
|
else if format=:'DATE' or format=:'DDMMYY' or format=:'MMDDYY'
|
|
@@ -61,5 +62,6 @@ data &outds(keep=name type length varnum format label ddtype);
|
|
|
61
62
|
end;
|
|
62
63
|
if label='' then label=name;
|
|
63
64
|
run;
|
|
64
|
-
|
|
65
|
+
proc sql;
|
|
66
|
+
drop table &dropds;
|
|
65
67
|
%mend mp_getcols;
|
package/base/mp_lockanytable.sas
CHANGED
|
@@ -14,19 +14,8 @@
|
|
|
14
14
|
@param [in] ref= A meaningful reference to enable the lock to be traced. Max
|
|
15
15
|
length is 200 characters.
|
|
16
16
|
@param [out] ctl_ds= (0) The control table which controls the actual locking.
|
|
17
|
-
Should already be assigned and available.
|
|
18
|
-
|
|
19
|
-
proc sql;
|
|
20
|
-
create table &ctl_ds(
|
|
21
|
-
lock_lib char(8),
|
|
22
|
-
lock_ds char(32),
|
|
23
|
-
lock_status_cd char(10) not null,
|
|
24
|
-
lock_user_nm char(100) not null ,
|
|
25
|
-
lock_ref char(200),
|
|
26
|
-
lock_pid char(10),
|
|
27
|
-
lock_start_dttm num format=E8601DT26.6,
|
|
28
|
-
lock_end_dttm num format=E8601DT26.6,
|
|
29
|
-
constraint pk_mp_lockanytable primary key(lock_lib,lock_ds));
|
|
17
|
+
Should already be assigned and available. The definition is available by
|
|
18
|
+
running mp_coretable.sas as follows: `mp_coretable(LOCKTABLE)`.
|
|
30
19
|
|
|
31
20
|
@param [in] loops= (25) Number of times to check for a lock.
|
|
32
21
|
@param [in] loop_secs= (1) Seconds to wait between each lock attempt
|
package/base/mp_retainedkey.sas
CHANGED
|
@@ -24,19 +24,12 @@
|
|
|
24
24
|
@li permlib.base_table - the target table to be loaded (**not** loaded by this
|
|
25
25
|
macro)
|
|
26
26
|
@li permlib.maxkeytable - optional, used to store load metaadata.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
label='The Retained key field containing the key values.',
|
|
34
|
-
max_key num label=
|
|
35
|
-
'Integer representing current max RK or SK value in the KEYTABLE',
|
|
36
|
-
processed_dttm num format=E8601DT26.6
|
|
37
|
-
label='Datetime this value was last updated',
|
|
38
|
-
constraint pk_mpe_maxkeyvalues
|
|
39
|
-
primary key(keytable));
|
|
27
|
+
The definition is available by running mp_coretable.sas as follows:
|
|
28
|
+
`mp_coretable(MAXKEYTABLE)`.
|
|
29
|
+
@li permlib.locktable - Necessary if maxkeytable is being populated. The
|
|
30
|
+
definition is available by running mp_coretable.sas as follows:
|
|
31
|
+
`mp_coretable(LOCKTABLE)`.
|
|
32
|
+
|
|
40
33
|
|
|
41
34
|
@param [in] base_lib= (WORK) Libref of the base (target) table.
|
|
42
35
|
@param [in] base_dsn= (BASETABLE) Name of the base (target) table.
|
|
@@ -72,6 +65,7 @@
|
|
|
72
65
|
@li mp_lockanytable.sas
|
|
73
66
|
|
|
74
67
|
<h4> Related Macros </h4>
|
|
68
|
+
@li mp_filterstore.sas
|
|
75
69
|
@li mp_retainedkey.test.sas
|
|
76
70
|
|
|
77
71
|
@version 9.2
|
|
@@ -101,7 +95,7 @@
|
|
|
101
95
|
%let tempds1=%mf_getuniquename();
|
|
102
96
|
%let tempds2=%mf_getuniquename();
|
|
103
97
|
%let comma_pk=%mf_getquotedstr(in_str=%str(&business_key),dlm=%str(,),quote=);
|
|
104
|
-
|
|
98
|
+
%let outds=%sysfunc(ifc(%index(&outds,.)=0,work.&outds,&outds));
|
|
105
99
|
/* validation checks */
|
|
106
100
|
%let iserr=0;
|
|
107
101
|
%if &syscc>0 %then %do;
|
|
@@ -132,14 +126,18 @@
|
|
|
132
126
|
%do x=1 %to %sysfunc(countw(&business_key));
|
|
133
127
|
/* check business key values exist */
|
|
134
128
|
%let key_field=%scan(&business_key,&x,%str( ));
|
|
135
|
-
%if
|
|
136
|
-
|
|
137
|
-
|
|
129
|
+
%if not %mf_existvar(&app_libds,&key_field) %then %do;
|
|
130
|
+
%let iserr=1;
|
|
131
|
+
%let msg=Business key (&key_field) not found on &app_libds!;
|
|
132
|
+
%goto err;
|
|
133
|
+
%end;
|
|
134
|
+
%else %if not %mf_existvar(&base_libds,&key_field) %then %do;
|
|
138
135
|
%let iserr=1;
|
|
139
|
-
%let msg=Business key (&key_field) not found!;
|
|
136
|
+
%let msg=Business key (&key_field) not found on &base_libds!;
|
|
137
|
+
%goto err;
|
|
140
138
|
%end;
|
|
141
139
|
%end;
|
|
142
|
-
|
|
140
|
+
%err:
|
|
143
141
|
%if &iserr=1 %then %do;
|
|
144
142
|
/* err case so first perform an unlock of the base table before exiting */
|
|
145
143
|
%mp_lockanytable(
|
|
@@ -203,7 +201,7 @@ quit;
|
|
|
203
201
|
* Update maxkey table if link provided
|
|
204
202
|
*/
|
|
205
203
|
%if &maxkeytable ne 0 %then %do;
|
|
206
|
-
proc sql;
|
|
204
|
+
proc sql noprint;
|
|
207
205
|
select count(*) into: check from &maxkeytable
|
|
208
206
|
where upcase(keytable)="&base_libds";
|
|
209
207
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sasjs/core",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "Macros for SAS Application Developers",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"SAS",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"ts-loader": "^9.2.6"
|
|
40
40
|
},
|
|
41
|
-
"version": "3.
|
|
41
|
+
"version": "3.7.3"
|
|
42
42
|
}
|