@sasjs/core 4.23.1 → 4.23.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.
package/README.md CHANGED
@@ -18,7 +18,7 @@
18
18
  [dependency-url]:https://github.com/sasjs/core/blob/main/package.json
19
19
 
20
20
 
21
- Much quality. Many standards. The **Macro Core** library exists to save time and development effort! Herein ye shall find a veritable host of MIT-licenced, production quality SAS macros. These are a mix of tools, utilities, functions and code generators that are useful in the context of [Application Development](https://sasapps.io) on the SAS platform (eg https://datacontroller.io). [Contributions](https://github.com/sasjs/core/blob/main/CONTRIBUTING.md) are welcomed.
21
+ Much quality. Many standards. The **Macro Core** library exists to save time and development effort! Herein ye shall find a veritable host of MIT-licenced, production quality SAS macros. These are a mix of tools, utilities, functions and code generators that are useful in the context of [Application Development](https://sasapps.io) on the SAS platform (eg https://datacontroller.io). [Contributions](https://github.com/sasjs/core/blob/main/.github/CONTRIBUTING.md) are welcome.
22
22
 
23
23
  You can download and compile them all in just two lines of SAS code:
24
24
 
@@ -224,12 +224,13 @@ The following repositories are also worth checking out:
224
224
  * [chris-swenson/sasmacros](https://github.com/chris-swenson/sasmacros)
225
225
  * [greg-wotton/sas-programs](https://github.com/greg-wootton/sas-programs)
226
226
  * [KatjaGlassConsulting/SMILE-SmartSASMacros](https://github.com/KatjaGlassConsulting/SMILE-SmartSASMacros)
227
+ * [rogerjdeangelis](https://github.com/rogerjdeangelis)
227
228
  * [scottbass/sas](https://github.com/scottbass/SAS)
228
229
  * [yabwon/sas_packages](https://github.com/yabwon/SAS_PACKAGES)
229
230
 
230
231
  ## Contributors ✨
231
232
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
232
- [![All Contributors](https://img.shields.io/badge/all_contributors-11-orange.svg?style=flat-square)](#contributors-)
233
+ [![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors-)
233
234
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
234
235
  Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
235
236
 
@@ -251,6 +252,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
251
252
  <td align="center"><a href="https://github.com/VladislavParhomchik"><img src="https://avatars.githubusercontent.com/u/83717836?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vladislav Parhomchik</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=VladislavParhomchik" title="Tests">⚠️</a> <a href="https://github.com/sasjs/core/pulls?q=is%3Apr+reviewed-by%3AVladislavParhomchik" title="Reviewed Pull Requests">👀</a></td>
252
253
  <td align="center"><a href="https://github.com/vznesh"><img src="https://avatars.githubusercontent.com/u/28916792?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vignesh T.</b></sub></a><br /><a href="https://github.com/sasjs/core/issues?q=author%3Avznesh" title="Bug reports">🐛</a></td>
253
254
  <td align="center"><a href="https://github.com/yabwon"><img src="https://avatars.githubusercontent.com/u/9314894?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bart Jablonski</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=yabwon" title="Code">💻</a></td>
255
+ <td align="center"><a href="https://bandism.net/"><img src="https://avatars.githubusercontent.com/u/22633385?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ikko Ashimine</b></sub></a><br /><a href="https://github.com/sasjs/core/commits?author=eltociear" title="Code">💻</a></td>
254
256
  </tr>
255
257
  </table>
256
258
 
@@ -65,7 +65,8 @@ proc sql;
65
65
  %end;
66
66
 
67
67
  %if &libds=0 %then %do;
68
+ proc sql;
68
69
  describe table &syslast;
69
70
  drop table &syslast;
70
71
  %end;
71
- %mend mp_coretable;
72
+ %mend mp_coretable;
@@ -11,7 +11,7 @@
11
11
 
12
12
  Usage:
13
13
 
14
- %mp_ds2cards(base_ds=sashelp.class
14
+ %mp_ds2cards(sashelp.class
15
15
  , tgt_ds=work.class
16
16
  , cards_file= "C:\temp\class.sas"
17
17
  , showlog=NO
@@ -23,7 +23,7 @@
23
23
  - explicity setting a unix LF
24
24
  - constraints / indexes etc
25
25
 
26
- @param [in] base_ds= Should be two level - eg work.blah. This is the table
26
+ @param [in] base_ds Should be two level - eg work.blah. This is the table
27
27
  that is converted to a cards file.
28
28
  @param [in] tgt_ds= Table that the generated cards file would create.
29
29
  Optional - if omitted, will be same as BASE_DS.
@@ -92,7 +92,36 @@ data &outds;
92
92
  /*length GROUP_LOGIC SUBGROUP_LOGIC $3 SUBGROUP_ID 8 VARIABLE_NM $32
93
93
  OPERATOR_NM $10 RAW_VALUE $4000;*/
94
94
  set &inds;
95
- length reason_cd $4032;
95
+ length reason_cd $4032 vtype $1 vnum dsid 8;
96
+
97
+ /* quick check to ensure column exists */
98
+ if upcase(VARIABLE_NM) not in
99
+ (%upcase(%mf_getvarlist(&targetds,dlm=%str(,),quote=SINGLE)))
100
+ then do;
101
+ REASON_CD="Variable "!!cats(variable_nm)!!" not in &targetds";
102
+ putlog REASON_CD= VARIABLE_NM=;
103
+ call symputx('reason_cd',reason_cd,'l');
104
+ call symputx('nobs',_n_,'l');
105
+ output;
106
+ return;
107
+ end;
108
+
109
+ /* need to open the dataset to get the column type */
110
+ dsid=open("&targetds","i");
111
+ if dsid>0 then do;
112
+ vnum=varnum(dsid,VARIABLE_NM);
113
+ if vnum<1 then do;
114
+ /* should not happen as was also tested for above */
115
+ REASON_CD=cats("Variable (",VARIABLE_NM,") not found in &targetds");
116
+ putlog REASON_CD= dsid=;
117
+ call symputx('reason_cd',reason_cd,'l');
118
+ call symputx('nobs',_n_,'l');
119
+ output;
120
+ return;
121
+ end;
122
+ /* now we can get the type */
123
+ else vtype=vartype(dsid,vnum);
124
+ end;
96
125
 
97
126
  /* closed list checks */
98
127
  if GROUP_LOGIC not in ('AND','OR') then do;
@@ -116,17 +145,8 @@ data &outds;
116
145
  call symputx('nobs',_n_,'l');
117
146
  output;
118
147
  end;
119
- if upcase(VARIABLE_NM) not in
120
- (%upcase(%mf_getvarlist(&targetds,dlm=%str(,),quote=SINGLE)))
121
- then do;
122
- REASON_CD="Variable "!!cats(variable_nm)!!" not in &targetds";
123
- putlog REASON_CD= VARIABLE_NM=;
124
- call symputx('reason_cd',reason_cd,'l');
125
- call symputx('nobs',_n_,'l');
126
- output;
127
- end;
128
148
  if OPERATOR_NM not in
129
- ('=','>','<','<=','>=','BETWEEN','IN','NOT IN','NE','CONTAINS','GE','LE')
149
+ ('=','>','<','<=','>=','NE','GE','LE','BETWEEN','IN','NOT IN','CONTAINS')
130
150
  then do;
131
151
  REASON_CD='Invalid OPERATOR_NM: '!!cats(OPERATOR_NM);
132
152
  putlog REASON_CD= OPERATOR_NM=;
@@ -135,6 +155,18 @@ data &outds;
135
155
  output;
136
156
  end;
137
157
 
158
+ /* special missing logic */
159
+ if vtype='N'
160
+ and OPERATOR_NM in ('=','>','<','<=','>=','NE','GE','LE')
161
+ and cats(upcase(raw_value)) in (
162
+ '.','.A','.B','.C','.D','.E','.F','.G','.H','.I','.J','.K','.L','.M','.N'
163
+ '.N','.O','.P','.Q','.R','.S','.T','.U','.V','.W','.X','.Y','.Z','._'
164
+ )
165
+ then do;
166
+ /* valid numeric - exit data step loop */
167
+ return;
168
+ end;
169
+
138
170
  /* special logic */
139
171
  if OPERATOR_NM='BETWEEN' then raw_value1=tranwrd(raw_value,' AND ','');
140
172
  else if OPERATOR_NM in ('IN','NOT IN') then do;
@@ -84,6 +84,9 @@ filename &outref temp;
84
84
  run;
85
85
  %end;
86
86
  %else %do;
87
+ proc sort data=&inds;
88
+ by SUBGROUP_ID;
89
+ run;
87
90
  data _null_;
88
91
  file &outref lrecl=32800;
89
92
  set &inds end=last;
@@ -40,6 +40,22 @@
40
40
  %let lib=%upcase(&lib);
41
41
  %let ds=%upcase(&ds);
42
42
 
43
+ /**
44
+ * Cater for environments where sashelp.vcncolu is not available
45
+ */
46
+ %if %sysfunc(exist(sashelp.vcncolu,view))=0 %then %do;
47
+ proc sql;
48
+ create table &outds(
49
+ libref char(8)
50
+ ,TABLE_NAME char(32)
51
+ ,constraint_type char(8) label='Constraint Type'
52
+ ,constraint_name char(32) label='Constraint Name'
53
+ ,column_name char(32) label='Column'
54
+ ,constraint_order num
55
+ );
56
+ %return;
57
+ %end;
58
+
43
59
  /**
44
60
  * Neither dictionary tables nor sashelp provides a constraint order column,
45
61
  * however they DO arrive in the correct order. So, create the col.
@@ -58,7 +58,7 @@
58
58
  %if %mf_getattrn(&libds,NLOBS)=0 %then %do;
59
59
  data &outds;
60
60
  length hashkey $32;
61
- retain hashkey "%sysfunc(md5(%str(&salt)),$hex32.)";
61
+ hashkey=put(md5("&salt"),$hex32.);
62
62
  output;
63
63
  stop;
64
64
  run;
@@ -69,9 +69,14 @@
69
69
  %put %str(ERR)OR: Dataset &libds is not a dataset;
70
70
  %end;
71
71
  %else %do;
72
- data &outds(rename=(&keyvar=hashkey) keep=&keyvar)/nonote2err;
72
+ data &outds(rename=(&keyvar=hashkey) keep=&keyvar)
73
+ %if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5" %then %do;
74
+ /nonote2err
75
+ %end;
76
+ ;
73
77
  length &prevkeyvar &keyvar $32;
74
- retain &prevkeyvar "%sysfunc(md5(%str(&salt)),$hex32.)";
78
+ retain &prevkeyvar;
79
+ if _n_=1 then &prevkeyvar=put(md5("&salt"),$hex32.);
75
80
  set &libds end=&lastvar;
76
81
  /* hash should include previous row */
77
82
  &keyvar=%mp_md5(
@@ -26,9 +26,19 @@
26
26
  oldval_num num format=best32. label='Old (numeric) value',
27
27
  newval_num num format=best32. label='New (numeric) value',
28
28
  oldval_char char(32765) label='Old (character) value',
29
- newval_char char(32765) label='New (character) value',
30
- constraint pk_mpe_audit
31
- primary key(load_ref,libref,dsn,key_hash,tgtvar_nm)
29
+ newval_char char(32765) label='New (character) value'
32
30
  );
33
31
 
32
+ %local lib;
33
+ %let libds=%upcase(&libds);
34
+ %if %index(&libds,.)=0 %then %let lib=WORK;
35
+ %else %let lib=%scan(&libds,1,.);
36
+
37
+ proc datasets lib=&lib noprint;
38
+ modify %scan(&libds,-1,.);
39
+ index create
40
+ pk_mpe_audit=(load_ref libref dsn key_hash tgtvar_nm)
41
+ /nomiss unique;
42
+ quit;
43
+
34
44
  %mend mddl_dc_difftable;
@@ -9,19 +9,32 @@
9
9
 
10
10
  %macro mddl_dc_filterdetail(libds=WORK.FILTER_DETAIL);
11
11
 
12
+ %local nn lib;
13
+ %if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5" %then %do;
14
+ %let nn=not null;
15
+ %end;
16
+ %else %let nn=;
17
+
12
18
  proc sql;
13
19
  create table &libds(
14
- filter_hash char(32) not null,
15
- filter_line num not null,
16
- group_logic char(3) not null,
17
- subgroup_logic char(3) not null,
18
- subgroup_id num not null,
19
- variable_nm varchar(32) not null,
20
- operator_nm varchar(12) not null,
21
- raw_value varchar(4000) not null,
22
- processed_dttm num not null format=E8601DT26.6,
23
- constraint pk_mpe_filteranytable
24
- primary key(filter_hash,filter_line)
20
+ filter_hash char(32) &nn,
21
+ filter_line num &nn,
22
+ group_logic char(3) &nn,
23
+ subgroup_logic char(3) &nn,
24
+ subgroup_id num &nn,
25
+ variable_nm varchar(32) &nn,
26
+ operator_nm varchar(12) &nn,
27
+ raw_value varchar(4000) &nn,
28
+ processed_dttm num &nn format=E8601DT26.6
25
29
  );
26
30
 
31
+ %let libds=%upcase(&libds);
32
+ %if %index(&libds,.)=0 %then %let lib=WORK;
33
+ %else %let lib=%scan(&libds,1,.);
34
+
35
+ proc datasets lib=&lib noprint;
36
+ modify %scan(&libds,-1,.);
37
+ index create pk_mpe_filterdetail=(filter_hash filter_line)/nomiss unique;
38
+ quit;
39
+
27
40
  %mend mddl_dc_filterdetail;
@@ -9,14 +9,27 @@
9
9
 
10
10
  %macro mddl_dc_filtersummary(libds=WORK.FILTER_SUMMARY);
11
11
 
12
+ %local nn lib;
13
+ %if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5" %then %do;
14
+ %let nn=not null;
15
+ %end;
16
+ %else %let nn=;
17
+
12
18
  proc sql;
13
19
  create table &libds(
14
- filter_rk num not null,
15
- filter_hash char(32) not null,
16
- filter_table char(41) not null,
17
- processed_dttm num not null format=E8601DT26.6,
18
- constraint pk_mpe_filteranytable
19
- primary key(filter_rk)
20
+ filter_rk num &nn,
21
+ filter_hash char(32) &nn,
22
+ filter_table char(41) &nn,
23
+ processed_dttm num &nn format=E8601DT26.6
20
24
  );
21
25
 
26
+ %let libds=%upcase(&libds);
27
+ %if %index(&libds,.)=0 %then %let lib=WORK;
28
+ %else %let lib=%scan(&libds,1,.);
29
+
30
+ proc datasets lib=&lib noprint;
31
+ modify %scan(&libds,-1,.);
32
+ index create filter_rk /nomiss unique;
33
+ quit;
34
+
22
35
  %mend mddl_dc_filtersummary;
@@ -9,17 +9,33 @@
9
9
 
10
10
  %macro mddl_dc_locktable(libds=WORK.LOCKTABLE);
11
11
 
12
+ %local nn lib;
13
+ %if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5" %then %do;
14
+ %let nn=not null;
15
+ %end;
16
+ %else %let nn=;
17
+
12
18
  proc sql;
13
19
  create table &libds(
14
20
  lock_lib char(8),
15
21
  lock_ds char(32),
16
- lock_status_cd char(10) not null,
17
- lock_user_nm char(100) not null ,
22
+ lock_status_cd char(10) &nn,
23
+ lock_user_nm char(100) &nn ,
18
24
  lock_ref char(200),
19
25
  lock_pid char(10),
20
26
  lock_start_dttm num format=E8601DT26.6,
21
- lock_end_dttm num format=E8601DT26.6,
22
- constraint pk_mp_lockanytable primary key(lock_lib,lock_ds)
27
+ lock_end_dttm num format=E8601DT26.6
23
28
  );
24
29
 
30
+ %let libds=%upcase(&libds);
31
+ %if %index(&libds,.)=0 %then %let lib=WORK;
32
+ %else %let lib=%scan(&libds,1,.);
33
+
34
+ proc datasets lib=&lib noprint;
35
+ modify %scan(&libds,-1,.);
36
+ index create
37
+ pk_mp_lockanytable=(lock_lib lock_ds)
38
+ /nomiss unique;
39
+ quit;
40
+
25
41
  %mend mddl_dc_locktable;
@@ -17,8 +17,17 @@
17
17
  max_key num label=
18
18
  'Integer representing current max RK or SK value in the KEYTABLE',
19
19
  processed_dttm num format=E8601DT26.6
20
- label='Datetime this value was last updated',
21
- constraint pk_mpe_maxkeyvalues
22
- primary key(keytable));
20
+ label='Datetime this value was last updated'
21
+ );
22
+
23
+ %local lib;
24
+ %let libds=%upcase(&libds);
25
+ %if %index(&libds,.)=0 %then %let lib=WORK;
26
+ %else %let lib=%scan(&libds,1,.);
27
+
28
+ proc datasets lib=&lib noprint;
29
+ modify %scan(&libds,-1,.);
30
+ index create keytable /nomiss unique;
31
+ quit;
23
32
 
24
33
  %mend mddl_dc_maxkeytable;
@@ -14,8 +14,8 @@ proc sql;
14
14
  create table &libds(
15
15
  FMTNAME char(32) label='Format name'
16
16
  /*
17
- to accomodate larger START values, mp_loadformat.sas will need the
18
- SQL dependency removed (proc sql needs to accomodate 3 index values in
17
+ to accommodate larger START values, mp_loadformat.sas will need the
18
+ SQL dependency removed (proc sql needs to accommodate 3 index values in
19
19
  a 32767 ibufsize limit)
20
20
  */
21
21
  ,START char(10000) label='Starting value for format'
@@ -40,4 +40,4 @@ create table &libds(
40
40
  ,LANGUAGE char(8) label='Language for date strings'
41
41
  );
42
42
 
43
- %mend mddl_sas_cntlout;
43
+ %mend mddl_sas_cntlout;
package/main.dox ADDED
@@ -0,0 +1,106 @@
1
+
2
+ /** \dir .
3
+ * \brief Open Source Macro Library for Developers of the SAS Language. See: https://github.com/sasjs/core
4
+ * \details To use - add the subfolders to your `SASAUTOS` call path.
5
+ */
6
+
7
+
8
+ /*! \dir base
9
+ * \brief Regular Base SAS Macros
10
+ * \details These macros have the following attributes:
11
+
12
+ * OS independent
13
+ * Not metadata aware
14
+ * No X command
15
+ * Prefixes: _mf_, _mp_
16
+
17
+ Macros starting `mf_` are macro _functions_ and can be used in assignment
18
+ statements. Those starting `mp_` are macro _procedures_, which generate
19
+ SAS statements, and must therefore be applied accordingly.
20
+
21
+ */
22
+
23
+ /*! \dir fcmp
24
+ * \brief Macros for generating FCMP functions
25
+ * \details These macros have the following attributes:
26
+
27
+ * Macro name matches compiled function / subroutine name
28
+ * Prefixes: _mcf_, _mcs_
29
+
30
+ The macro part is just a wrapper for the underlying function / subroutine,
31
+ and has switches for including the proc fcmp / quit statements and whether
32
+ to insert the package into the CMPLIB option.
33
+
34
+ */
35
+
36
+ /*! \dir meta
37
+ * \brief Metadata Aware Macros
38
+ * \details These macros have the following attributes:
39
+
40
+ * OS independent
41
+ * Metadata aware
42
+ * No X command
43
+ * Prefixes: _mm_
44
+
45
+ */
46
+
47
+ /*! \dir metax
48
+ * \brief Metadata Aware Macros with X commmand
49
+ * \details These macros have the following attributes:
50
+
51
+ * OS independent
52
+ * Metadata aware
53
+ * X command
54
+ * Prefixes: _mmx_, _mmw_, _mmu_
55
+
56
+ */
57
+
58
+ /*! \dir server
59
+ * \brief Macros used with [sasjs/server](https://server.sasjs.io)
60
+ * \details These macros have the following attributes:
61
+
62
+ * OS independent
63
+ * sasjs/server aware
64
+ * No X command
65
+ * Prefixes: _ms_
66
+
67
+ */
68
+
69
+ /*! \dir tests
70
+ * \brief SASjs Tests
71
+ * \details These folders contain the macro tests. They are first compiled
72
+ and deployed (sasjs cbd) then executed (sasjs test).
73
+
74
+ */
75
+
76
+ /*! \dir viya
77
+ * \brief Viya macros
78
+ * \details These macros have the following attributes:
79
+
80
+ * OS independent
81
+ * No X command
82
+ * Prefixes: _mv_
83
+
84
+ */
85
+
86
+ /*! \dir lua
87
+ * \brief Lua macros
88
+ * \details These macros have the following attributes:
89
+
90
+ * OS independent
91
+ * Work as LUA functions (they are immediately executed/compiled)
92
+ * Auto-generated from the plain source `.lua` files in the same directory
93
+ * Prefixes: _ml_
94
+
95
+ */
96
+
97
+ /*! \dir ddl
98
+ * \brief Data Definition Language files
99
+ * \details Provides templates for commonly used tables in sasjs/core.
100
+ Attributes:
101
+
102
+ * OS independent
103
+ * No X command
104
+ * Prefixes: _mddl_
105
+
106
+ */
package/package.json CHANGED
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "@sasjs/cli": "3.13.0"
37
37
  },
38
- "version": "4.23.1"
38
+ "version": "4.23.4"
39
39
  }