@sasjs/core 4.46.1 → 4.46.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_cntlout.sas +11 -3
- package/base/mp_ds2md.sas +1 -0
- package/base/mp_loadformat.sas +35 -31
- package/base/mp_lockanytable.sas +29 -25
- package/base/mp_storediffs.sas +3 -3
- package/ddl/mddl_sas_cntlout.sas +21 -13
- package/package.json +1 -1
package/base/mp_cntlout.sas
CHANGED
|
@@ -67,16 +67,24 @@ proc format lib=&libcat cntlout=&cntlds;
|
|
|
67
67
|
%end;
|
|
68
68
|
run;
|
|
69
69
|
|
|
70
|
-
data &cntlout;
|
|
70
|
+
data &cntlout/nonote2err;
|
|
71
71
|
if 0 then set &ddlds;
|
|
72
72
|
set &cntlds;
|
|
73
|
-
|
|
73
|
+
by type fmtname notsorted;
|
|
74
|
+
|
|
75
|
+
/* align the numeric values to avoid overlapping ranges */
|
|
76
|
+
if type in ("I","N") then do;
|
|
74
77
|
%mp_aligndecimal(start,width=16)
|
|
75
78
|
%mp_aligndecimal(end,width=16)
|
|
76
79
|
end;
|
|
80
|
+
|
|
81
|
+
/* create row marker. Data cannot be sorted without it! */
|
|
82
|
+
if first.fmtname then fmtrow=0;
|
|
83
|
+
fmtrow+1;
|
|
84
|
+
|
|
77
85
|
run;
|
|
78
86
|
proc sort;
|
|
79
|
-
by type fmtname
|
|
87
|
+
by type fmtname fmtrow;
|
|
80
88
|
run;
|
|
81
89
|
|
|
82
90
|
proc sql;
|
package/base/mp_ds2md.sas
CHANGED
package/base/mp_loadformat.sas
CHANGED
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages and preserve outputs
|
|
35
35
|
|
|
36
36
|
<h4> SAS Macros </h4>
|
|
37
|
-
@li mddl_sas_cntlout.sas
|
|
38
37
|
@li mf_getuniquename.sas
|
|
39
38
|
@li mf_nobs.sas
|
|
40
39
|
@li mp_abort.sas
|
|
@@ -46,7 +45,8 @@
|
|
|
46
45
|
<h4> Related Macros </h4>
|
|
47
46
|
@li mddl_dc_difftable.sas
|
|
48
47
|
@li mddl_dc_locktable.sas
|
|
49
|
-
@li mp_loadformat.test.sas
|
|
48
|
+
@li mp_loadformat.test.1.sas
|
|
49
|
+
@li mp_loadformat.test.2.sas
|
|
50
50
|
@li mp_lockanytable.sas
|
|
51
51
|
@li mp_stackdiffs.sas
|
|
52
52
|
|
|
@@ -79,13 +79,6 @@
|
|
|
79
79
|
%let &var=%upcase(&prefix._&var);
|
|
80
80
|
%end;
|
|
81
81
|
|
|
82
|
-
/*
|
|
83
|
-
format values can be up to 32767 wide. SQL joins on such a wide column can
|
|
84
|
-
cause buffer issues. Update ibufsize and reset at the end.
|
|
85
|
-
*/
|
|
86
|
-
%let ibufsize=%sysfunc(getoption(ibufsize));
|
|
87
|
-
options ibufsize=32767 ;
|
|
88
|
-
|
|
89
82
|
/* in DC, format catalogs maybe specified in the libds with a -FC extension */
|
|
90
83
|
%let libcat=%scan(&libcat,1,-);
|
|
91
84
|
|
|
@@ -148,16 +141,24 @@ select distinct
|
|
|
148
141
|
|
|
149
142
|
%mp_cntlout(libcat=&libcat,fmtlist=&fmtlist,cntlout=&base_fmts)
|
|
150
143
|
|
|
144
|
+
/* get a hash of the row */
|
|
145
|
+
%local cvars nvars;
|
|
146
|
+
%let cvars=TYPE FMTNAME START END LABEL PREFIX FILL SEXCL EEXCL HLO DECSEP
|
|
147
|
+
DIG3SEP DATATYPE LANGUAGE;
|
|
148
|
+
%let nvars=FMTROW MIN MAX DEFAULT LENGTH FUZZ MULT NOEDIT;
|
|
149
|
+
data &base_fmts/note2err;
|
|
150
|
+
set &base_fmts;
|
|
151
|
+
fmthash=%mp_md5(cvars=&cvars, nvars=&nvars);
|
|
152
|
+
run;
|
|
151
153
|
|
|
152
154
|
/**
|
|
153
155
|
* Ensure input table and base_formats have consistent lengths and types
|
|
154
156
|
*/
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if 0 then set &template;
|
|
159
|
-
length start end $10000;
|
|
157
|
+
data &inlibds/nonote2err;
|
|
158
|
+
length &delete_col $3 FMTROW 8 start end label $32767;
|
|
159
|
+
if 0 then set &base_fmts;
|
|
160
160
|
set &libds;
|
|
161
|
+
by type fmtname notsorted;
|
|
161
162
|
if &delete_col='' then &delete_col='No';
|
|
162
163
|
fmtname=upcase(fmtname);
|
|
163
164
|
type=upcase(type);
|
|
@@ -175,6 +176,14 @@ data &inlibds;
|
|
|
175
176
|
%mp_aligndecimal(start,width=16)
|
|
176
177
|
%mp_aligndecimal(end,width=16)
|
|
177
178
|
end;
|
|
179
|
+
|
|
180
|
+
/* update row marker - retain new var as fmtrow may already be in libds */
|
|
181
|
+
if first.fmtname then row=1;
|
|
182
|
+
else row+1;
|
|
183
|
+
drop row;
|
|
184
|
+
fmtrow=row;
|
|
185
|
+
|
|
186
|
+
fmthash=%mp_md5(cvars=&cvars, nvars=&nvars);
|
|
178
187
|
run;
|
|
179
188
|
|
|
180
189
|
/**
|
|
@@ -185,12 +194,10 @@ create table &outds_add(drop=&delete_col) as
|
|
|
185
194
|
select a.*
|
|
186
195
|
from &inlibds a
|
|
187
196
|
left join &base_fmts b
|
|
188
|
-
on a.fmtname=b.fmtname
|
|
189
|
-
and a.start=b.start
|
|
190
|
-
and a.type=b.type
|
|
197
|
+
on a.type=b.type and a.fmtname=b.fmtname and a.fmtrow=b.fmtrow
|
|
191
198
|
where b.fmtname is null
|
|
192
199
|
and upcase(a.&delete_col) ne "YES"
|
|
193
|
-
order by type, fmtname,
|
|
200
|
+
order by type, fmtname, fmtrow;
|
|
194
201
|
|
|
195
202
|
/**
|
|
196
203
|
* Identify deleted records
|
|
@@ -199,11 +206,9 @@ create table &outds_del(drop=&delete_col) as
|
|
|
199
206
|
select a.*
|
|
200
207
|
from &inlibds a
|
|
201
208
|
inner join &base_fmts b
|
|
202
|
-
on a.fmtname=b.fmtname
|
|
203
|
-
and a.start=b.start
|
|
204
|
-
and a.type=b.type
|
|
209
|
+
on a.type=b.type and a.fmtname=b.fmtname and a.fmtrow=b.fmtrow
|
|
205
210
|
where upcase(a.&delete_col)="YES"
|
|
206
|
-
order by type, fmtname,
|
|
211
|
+
order by type, fmtname, fmtrow;
|
|
207
212
|
|
|
208
213
|
/**
|
|
209
214
|
* Identify modified records
|
|
@@ -212,13 +217,10 @@ create table &outds_mod (drop=&delete_col) as
|
|
|
212
217
|
select a.*
|
|
213
218
|
from &inlibds a
|
|
214
219
|
inner join &base_fmts b
|
|
215
|
-
on a.fmtname=b.fmtname
|
|
216
|
-
and a.start=b.start
|
|
217
|
-
and a.type=b.type
|
|
220
|
+
on a.type=b.type and a.fmtname=b.fmtname and a.fmtrow=b.fmtrow
|
|
218
221
|
where upcase(a.&delete_col) ne "YES"
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
options ibufsize=&ibufsize;
|
|
222
|
+
and a.fmthash ne b.fmthash
|
|
223
|
+
order by type, fmtname, fmtrow;
|
|
222
224
|
|
|
223
225
|
%mp_abort(
|
|
224
226
|
iftrue=(&syscc ne 0)
|
|
@@ -227,19 +229,21 @@ options ibufsize=&ibufsize;
|
|
|
227
229
|
)
|
|
228
230
|
|
|
229
231
|
%if &loadtarget=YES %then %do;
|
|
232
|
+
/* new records plus base records that are not deleted or modified */
|
|
230
233
|
data &ds1;
|
|
231
234
|
merge &base_fmts(in=base)
|
|
232
235
|
&outds_mod(in=mod)
|
|
233
236
|
&outds_add(in=add)
|
|
234
237
|
&outds_del(in=del);
|
|
235
238
|
if not del and not mod;
|
|
236
|
-
by type fmtname
|
|
239
|
+
by type fmtname fmtrow;
|
|
237
240
|
run;
|
|
241
|
+
/* add back the modified records */
|
|
238
242
|
data &stagedata;
|
|
239
243
|
set &ds1 &outds_mod;
|
|
240
244
|
run;
|
|
241
245
|
proc sort;
|
|
242
|
-
by type fmtname
|
|
246
|
+
by type fmtname fmtrow;
|
|
243
247
|
run;
|
|
244
248
|
%end;
|
|
245
249
|
/* mp abort needs to run outside of conditional blocks */
|
|
@@ -287,7 +291,7 @@ options ibufsize=&ibufsize;
|
|
|
287
291
|
|
|
288
292
|
%mp_storediffs(&libcat-FC
|
|
289
293
|
,&base_fmts
|
|
290
|
-
,TYPE FMTNAME
|
|
294
|
+
,TYPE FMTNAME FMTROW
|
|
291
295
|
,delds=&outds_del
|
|
292
296
|
,modds=&outds_mod
|
|
293
297
|
,appds=&outds_add
|
package/base/mp_lockanytable.sas
CHANGED
|
@@ -194,35 +194,39 @@ run;
|
|
|
194
194
|
%end;
|
|
195
195
|
%end;
|
|
196
196
|
%else %if &ACTION=UNLOCK %then %do;
|
|
197
|
-
%local status;
|
|
197
|
+
%local status cnt;
|
|
198
|
+
%let cnt=0;
|
|
198
199
|
proc sql noprint;
|
|
199
|
-
select
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
%if &syscc>0 %then %put syscc=&syscc sqlrc=&sqlrc;
|
|
203
|
-
%if &sqlobs=0 %then %do;
|
|
204
|
-
%put %str(WAR)NING: &lib..&ds has never been locked!;
|
|
200
|
+
select count(*) into: cnt from &ctl_ds where LOCK_LIB ="&lib" & LOCK_DS="&ds";
|
|
201
|
+
%if &cnt=0 %then %do;
|
|
202
|
+
%put %str(WAR)NING: &lib..&ds was not previously locked in &ctl_ds!;
|
|
205
203
|
%end;
|
|
206
|
-
%else %
|
|
207
|
-
|
|
208
|
-
putlog "&sysmacroname: unlocking &lib..&ds:";
|
|
209
|
-
run;
|
|
210
|
-
proc sql;
|
|
211
|
-
update &ctl_ds
|
|
212
|
-
set LOCK_STATUS_CD='UNLOCKED'
|
|
213
|
-
, LOCK_END_DTTM="%sysfunc(datetime(),%mf_fmtdttm())"dt
|
|
214
|
-
, LOCK_USER_NM="&user"
|
|
215
|
-
, LOCK_PID="&sysjobid"
|
|
216
|
-
, LOCK_REF="&ref"
|
|
204
|
+
%else %do;
|
|
205
|
+
select LOCK_STATUS_CD into: status from &ctl_ds
|
|
217
206
|
where LOCK_LIB ="&lib" and LOCK_DS="&ds";
|
|
218
207
|
quit;
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
208
|
+
%if &syscc>0 %then %put syscc=&syscc sqlrc=&sqlrc;
|
|
209
|
+
%if &status=LOCKED %then %do;
|
|
210
|
+
data _null_;
|
|
211
|
+
putlog "&sysmacroname: unlocking &lib..&ds:";
|
|
212
|
+
run;
|
|
213
|
+
proc sql;
|
|
214
|
+
update &ctl_ds
|
|
215
|
+
set LOCK_STATUS_CD='UNLOCKED'
|
|
216
|
+
, LOCK_END_DTTM="%sysfunc(datetime(),%mf_fmtdttm())"dt
|
|
217
|
+
, LOCK_USER_NM="&user"
|
|
218
|
+
, LOCK_PID="&sysjobid"
|
|
219
|
+
, LOCK_REF="&ref"
|
|
220
|
+
where LOCK_LIB ="&lib" and LOCK_DS="&ds";
|
|
221
|
+
quit;
|
|
222
|
+
%end;
|
|
223
|
+
%else %if &status=UNLOCKED %then %do;
|
|
224
|
+
%put %str(WAR)NING: &lib..&ds is already unlocked!;
|
|
225
|
+
%end;
|
|
226
|
+
%else %do;
|
|
227
|
+
%put NOTE: Unrecognised STATUS_CD (&status) in &ctl_ds;
|
|
228
|
+
%let abortme=1;
|
|
229
|
+
%end;
|
|
226
230
|
%end;
|
|
227
231
|
%end;
|
|
228
232
|
%else %do;
|
package/base/mp_storediffs.sas
CHANGED
|
@@ -147,9 +147,9 @@ run;
|
|
|
147
147
|
|
|
148
148
|
%if %index(&libds,-)>0 and %scan(&libds,2,-)=FC %then %do;
|
|
149
149
|
/* this is a format catalog - cannot query cols directly */
|
|
150
|
-
%let vlist="FMTNAME","START","END","LABEL","MIN","MAX"
|
|
151
|
-
,"FUZZ","PREFIX","MULT","FILL","NOEDIT","
|
|
152
|
-
,"DECSEP","DIG3SEP","DATATYPE","LANGUAGE";
|
|
150
|
+
%let vlist="TYPE","FMTNAME","FMTROW","START","END","LABEL","MIN","MAX"
|
|
151
|
+
,"DEFAULT","LENGTH","FUZZ","PREFIX","MULT","FILL","NOEDIT","SEXCL"
|
|
152
|
+
,"EEXCL","HLO","DECSEP","DIG3SEP","DATATYPE","LANGUAGE";
|
|
153
153
|
%end;
|
|
154
154
|
%else %let vlist=%mf_getvarlist(&libds,dlm=%str(,),quote=DOUBLE);
|
|
155
155
|
|
package/ddl/mddl_sas_cntlout.sas
CHANGED
|
@@ -11,22 +11,18 @@
|
|
|
11
11
|
|
|
12
12
|
%macro mddl_sas_cntlout(libds=WORK.CNTLOUT);
|
|
13
13
|
|
|
14
|
-
proc sql;
|
|
15
|
-
create table &libds(
|
|
16
|
-
TYPE char(1)
|
|
17
|
-
,FMTNAME char(32)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
SQL dependency removed (proc sql needs to accommodate 3 index values in
|
|
21
|
-
a 32767 ibufsize limit)
|
|
22
|
-
*/
|
|
23
|
-
,START char(10000) label='Starting value for format'
|
|
14
|
+
proc sql;
|
|
15
|
+
create table &libds(
|
|
16
|
+
TYPE char(1) label='Type of format - either N (num fmt), C (char fmt), I (num infmt) or J (char infmt)'
|
|
17
|
+
,FMTNAME char(32) label='Format name'
|
|
18
|
+
,FMTROW num label='CALCULATED Position of record by FMTNAME (reqd for multilabel formats)'
|
|
19
|
+
,START char(32767) label='Starting value for format'
|
|
24
20
|
/*
|
|
25
21
|
Keep lengths of START and END the same to avoid this err:
|
|
26
22
|
"Start is greater than end: -<."
|
|
27
23
|
Similar usage note: https://support.sas.com/kb/69/330.html
|
|
28
24
|
*/
|
|
29
|
-
,END char(
|
|
25
|
+
,END char(32767) label='Ending value for format'
|
|
30
26
|
,LABEL char(32767) label='Format value label'
|
|
31
27
|
,MIN num length=3 label='Minimum length'
|
|
32
28
|
,MAX num length=3 label='Maximum length'
|
|
@@ -39,11 +35,23 @@ create table &libds(
|
|
|
39
35
|
,NOEDIT num length=3 label='Is picture string noedit?'
|
|
40
36
|
,SEXCL char(1) label='Start exclusion'
|
|
41
37
|
,EEXCL char(1) label='End exclusion'
|
|
42
|
-
,HLO char(13) label='Additional information'
|
|
38
|
+
,HLO char(13) label='Additional information. M=MultiLabel'
|
|
43
39
|
,DECSEP char(1) label='Decimal separator'
|
|
44
40
|
,DIG3SEP char(1) label='Three-digit separator'
|
|
45
41
|
,DATATYPE char(8) label='Date/time/datetime?'
|
|
46
42
|
,LANGUAGE char(8) label='Language for date strings'
|
|
47
|
-
);
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
%local lib;
|
|
46
|
+
%let libds=%upcase(&libds);
|
|
47
|
+
%if %index(&libds,.)=0 %then %let lib=WORK;
|
|
48
|
+
%else %let lib=%scan(&libds,1,.);
|
|
49
|
+
|
|
50
|
+
proc datasets lib=&lib noprint;
|
|
51
|
+
modify %scan(&libds,-1,.);
|
|
52
|
+
index create
|
|
53
|
+
pk_cntlout=(type fmtname fmtrow)
|
|
54
|
+
/nomiss unique;
|
|
55
|
+
quit;
|
|
48
56
|
|
|
49
57
|
%mend mddl_sas_cntlout;
|
package/package.json
CHANGED