@sasjs/core 4.46.3 → 4.46.4

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.
@@ -10,10 +10,9 @@
10
10
 
11
11
  returns:
12
12
 
13
- > DOLLAR $CHAR W MONNAME
14
- > $CHAR BEST DOLLAR
15
- > BEST Z $CHAR COMMA PERCENTN
16
-
13
+ DOLLAR $CHAR W MONNAME
14
+ $CHAR BEST DOLLAR
15
+ BEST Z $CHAR COMMA PERCENTN
17
16
 
18
17
  @param [in] libds Two part library.dataset reference.
19
18
 
@@ -58,9 +58,9 @@
58
58
  %end;
59
59
 
60
60
  proc format lib=&libcat cntlout=&cntlds;
61
- %if "&fmtlist" ne "0" %then %do;
61
+ %if "&fmtlist" ne "0" and "&fmtlist" ne "" %then %do;
62
62
  select
63
- %do i=1 %to %sysfunc(countw(&fmtlist));
63
+ %do i=1 %to %sysfunc(countw(&fmtlist,%str( )));
64
64
  %scan(&fmtlist,&i,%str( ))
65
65
  %end;
66
66
  ;
@@ -7,10 +7,15 @@
7
7
  Formats are taken from the library / dataset reference and / or a static
8
8
  format list.
9
9
 
10
+ Note - the source for this information is the dictionary.formats table. This
11
+ cannot show formats that are not already declared in the FMTSEARCH path.
12
+
10
13
  Example usage:
11
14
 
12
15
  %mp_getformats(lib=sashelp,ds=prdsale,outsummary=work.dictable)
13
16
 
17
+ %mp_getformats(fmtlist=FORMAT1 $FORMAT2 @INFMT3,outsummary=work.table2)
18
+
14
19
  @param [in] lib= (0) The libref for which to return formats.
15
20
  @todo Enable exporting of formats for an entire library
16
21
  @param [in] ds= (0) The dataset from which to obtain format definitions
@@ -49,7 +54,9 @@ https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#
49
54
 
50
55
 
51
56
  <h4> Related Macros </h4>
57
+ @li mf_getfmtlist.sas
52
58
  @li mp_applyformats.sas
59
+ @li mp_cntlout.sas
53
60
  @li mp_getformats.test.sas
54
61
 
55
62
  @version 9.2
@@ -66,7 +73,7 @@ https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#
66
73
 
67
74
  %local i fmt allfmts tempds fmtcnt;
68
75
 
69
- %if "&fmtlist" ne "0" %then %do i=1 %to %sysfunc(countw(&fmtlist,,%str( )));
76
+ %if "&fmtlist" ne "0" %then %do i=1 %to %sysfunc(countw(&fmtlist,%str( )));
70
77
  /* ensure format list contains format _name_ only */
71
78
  %let fmt=%scan(&fmtlist,&i,%str( ));
72
79
  %let fmt=%mf_getfmtname(&fmt);
@@ -90,8 +97,7 @@ https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#
90
97
  proc sql;
91
98
  create table &outsummary as
92
99
  select * from dictionary.formats
93
- where fmtname in (%mf_getquotedstr(&allfmts,quote=D))
94
- and fmttype='F';
100
+ where fmtname in (%mf_getquotedstr(&allfmts,quote=D));
95
101
 
96
102
  %if "&outdetail" ne "0" %then %do;
97
103
  /* ensure base table always exists */
@@ -115,6 +121,10 @@ create table &outsummary as
115
121
  data &tempds;
116
122
  if 0 then set &outdetail;
117
123
  set &tempds;
124
+ /* set fmtrow (position of record within the format) */
125
+ by type fmtname notsorted;
126
+ if first.fmtname then fmtrow=1;
127
+ else fmtrow+1;
118
128
  run;
119
129
  proc append base=&outdetail data=&tempds ;
120
130
  run;
@@ -68,7 +68,7 @@
68
68
  );
69
69
  /* set up local macro variables and temporary tables (with a prefix) */
70
70
  %local err msg prefix dslist i var fmtlist ibufsize;
71
- %let dslist=base_fmts template inlibds ds1 stagedata storediffs;
71
+ %let dslist=base_fmts template inlibds ds1 stagedata storediffs del1 del2;
72
72
  %if &outds_add=0 %then %let dslist=&dslist outds_add;
73
73
  %if &outds_del=0 %then %let dslist=&dslist outds_del;
74
74
  %if &outds_mod=0 %then %let dslist=&dslist outds_mod;
@@ -200,28 +200,47 @@ create table &outds_add(drop=&delete_col) as
200
200
  order by type, fmtname, fmtrow;
201
201
 
202
202
  /**
203
- * Identify deleted records
203
+ * Identify modified records
204
204
  */
205
- create table &outds_del(drop=&delete_col) as
205
+ create table &outds_mod (drop=&delete_col) as
206
206
  select a.*
207
207
  from &inlibds a
208
208
  inner join &base_fmts b
209
209
  on a.type=b.type and a.fmtname=b.fmtname and a.fmtrow=b.fmtrow
210
- where upcase(a.&delete_col)="YES"
210
+ where upcase(a.&delete_col) ne "YES"
211
+ and a.fmthash ne b.fmthash
211
212
  order by type, fmtname, fmtrow;
212
213
 
213
214
  /**
214
- * Identify modified records
215
+ * Identify deleted records
215
216
  */
216
- create table &outds_mod (drop=&delete_col) as
217
+ create table &outds_del(drop=&delete_col) as
217
218
  select a.*
218
219
  from &inlibds a
219
220
  inner join &base_fmts b
220
221
  on a.type=b.type and a.fmtname=b.fmtname and a.fmtrow=b.fmtrow
221
- where upcase(a.&delete_col) ne "YES"
222
- and a.fmthash ne b.fmthash
222
+ where upcase(a.&delete_col)="YES"
223
223
  order by type, fmtname, fmtrow;
224
224
 
225
+ /**
226
+ * Identify fully deleted formats (where every record is removed)
227
+ * These require to be explicitly deleted in proc format
228
+ * del1 - identify _partial_ deletes
229
+ * del2 - exclude these, and also formats that come with _additions_
230
+ */
231
+ create table &del1 as
232
+ select a.*
233
+ from &base_fmts a
234
+ left join &outds_del b
235
+ on a.type=b.type and a.fmtname=b.fmtname and a.fmtrow=b.fmtrow
236
+ where b.fmtrow is null;
237
+
238
+ create table &del2 as
239
+ select * from &outds_del
240
+ where cats(type,fmtname) not in (select cats(type,fmtname) from &outds_add)
241
+ and cats(type,fmtname) not in (select cats(type,fmtname) from &del1);
242
+
243
+
225
244
  %mp_abort(
226
245
  iftrue=(&syscc ne 0)
227
246
  ,mac=&sysmacroname
@@ -253,7 +272,7 @@ create table &outds_mod (drop=&delete_col) as
253
272
  ,msg=%str(SYSCC=&syscc prior to actual load)
254
273
  )
255
274
  %if &loadtarget=YES %then %do;
256
- %if %mf_nobs(&stagedata)=0 %then %do;
275
+ %if %mf_nobs(&stagedata)=0 and %mf_nobs(&del2)=0 %then %do;
257
276
  %put There are no changes to load in &libcat!;
258
277
  %return;
259
278
  %end;
@@ -269,6 +288,22 @@ create table &outds_mod (drop=&delete_col) as
269
288
  /* do the actual load */
270
289
  proc format lib=&libcat cntlin=&stagedata;
271
290
  run;
291
+ /* apply any full deletes */
292
+ %if %mf_nobs(&del2)>0 %then %do;
293
+ %local delfmtlist;
294
+ proc sql noprint;
295
+ select distinct case when type='N' then cats(fmtname,'.FORMAT')
296
+ when type='C' then cats(fmtname,'.FORMATC')
297
+ when type='J' then cats(fmtname,'.INFMTC')
298
+ when type='I' then cats(fmtname,'.INFMT')
299
+ else cats(fmtname,'.BADENTRY!!!') end
300
+ into: delfmtlist
301
+ separated by ' '
302
+ from &del2;
303
+ proc catalog catalog=&libcat;
304
+ delete &delfmtlist;
305
+ quit;
306
+ %end;
272
307
  %if &locklibds ne 0 %then %do;
273
308
  /* unlock the table */
274
309
  %mp_lockanytable(UNLOCK
@@ -165,7 +165,7 @@ data &ds4;
165
165
  if upcase(&inds_auto)="&ds2" then tgtvar_type='N';
166
166
  else if upcase(&inds_auto)="&ds3" then tgtvar_type='C';
167
167
  else do;
168
- putlog "%str(ERR)OR: unidentified vartype input!" &inds_auto;
168
+ putlog 'ERR' +(-1) "OR: unidentified vartype input!" &inds_auto;
169
169
  call symputx('syscc',98);
170
170
  end;
171
171
 
@@ -174,7 +174,7 @@ data &ds4;
174
174
  else if &inds_keep="&modds" then move_type='M';
175
175
  else if &inds_keep="&origds" then move_type='O';
176
176
  else do;
177
- putlog "%str(ERR)OR: unidentified movetype input!" &inds_keep;
177
+ putlog 'ERR' +(-1) "OR: unidentified movetype input!" &inds_keep;
178
178
  call symputx('syscc',99);
179
179
  end;
180
180
  tgtvar_nm=upcase(tgtvar_nm);
package/package.json CHANGED
@@ -33,7 +33,7 @@
33
33
  "prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true"
34
34
  },
35
35
  "devDependencies": {
36
- "@sasjs/cli": "3.24.0"
36
+ "@sasjs/cli": "^4.4.1"
37
37
  },
38
- "version": "4.46.3"
38
+ "version": "4.46.4"
39
39
  }