@sasjs/core 4.23.2 → 4.23.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.
@@ -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;
@@ -69,7 +69,11 @@
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
78
  retain &prevkeyvar "%sysfunc(md5(%str(&salt)),$hex32.)";
75
79
  set &libds end=&lastvar;
@@ -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;
package/main.dox CHANGED
@@ -92,4 +92,15 @@
92
92
  * Auto-generated from the plain source `.lua` files in the same directory
93
93
  * Prefixes: _ml_
94
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
+
95
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.2"
38
+ "version": "4.23.3"
39
39
  }