@sasjs/core 4.48.4 → 4.49.0
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_filtercheck.sas +99 -12
- package/package.json +1 -1
package/base/mp_filtercheck.sas
CHANGED
|
@@ -86,15 +86,14 @@
|
|
|
86
86
|
/**
|
|
87
87
|
* Sanitise the values based on valid value lists, then strip out
|
|
88
88
|
* quotes, commas, periods and spaces.
|
|
89
|
-
* Only numeric values should remain
|
|
90
89
|
*/
|
|
91
90
|
%local reason_cd nobs;
|
|
92
91
|
%let nobs=0;
|
|
93
92
|
data &outds;
|
|
94
93
|
/*length GROUP_LOGIC SUBGROUP_LOGIC $3 SUBGROUP_ID 8 VARIABLE_NM $32
|
|
95
94
|
OPERATOR_NM $10 RAW_VALUE $4000;*/
|
|
96
|
-
set &inds;
|
|
97
|
-
length reason_cd $4032 vtype $1 vnum dsid 8 tmp $4000;
|
|
95
|
+
set &inds end=last;
|
|
96
|
+
length reason_cd $4032 vtype vtype2 $1 vnum dsid 8 tmp $4000;
|
|
98
97
|
drop tmp;
|
|
99
98
|
|
|
100
99
|
/* quick check to ensure column exists */
|
|
@@ -110,7 +109,8 @@ data &outds;
|
|
|
110
109
|
end;
|
|
111
110
|
|
|
112
111
|
/* need to open the dataset to get the column type */
|
|
113
|
-
dsid
|
|
112
|
+
retain dsid;
|
|
113
|
+
if _n_=1 then dsid=open("&targetds","i");
|
|
114
114
|
if dsid>0 then do;
|
|
115
115
|
vnum=varnum(dsid,VARIABLE_NM);
|
|
116
116
|
if vnum<1 then do;
|
|
@@ -120,11 +120,19 @@ data &outds;
|
|
|
120
120
|
call symputx('reason_cd',reason_cd,'l');
|
|
121
121
|
call symputx('nobs',_n_,'l');
|
|
122
122
|
output;
|
|
123
|
-
|
|
123
|
+
goto endstep;
|
|
124
124
|
end;
|
|
125
125
|
/* now we can get the type */
|
|
126
126
|
else vtype=vartype(dsid,vnum);
|
|
127
127
|
end;
|
|
128
|
+
else do;
|
|
129
|
+
REASON_CD=cats("Could not open &targetds");
|
|
130
|
+
putlog REASON_CD= dsid=;
|
|
131
|
+
call symputx('reason_cd',reason_cd,'l');
|
|
132
|
+
call symputx('nobs',_n_,'l');
|
|
133
|
+
output;
|
|
134
|
+
stop;
|
|
135
|
+
end;
|
|
128
136
|
|
|
129
137
|
/* closed list checks */
|
|
130
138
|
if GROUP_LOGIC not in ('AND','OR') then do;
|
|
@@ -159,15 +167,40 @@ data &outds;
|
|
|
159
167
|
end;
|
|
160
168
|
|
|
161
169
|
/* special missing logic */
|
|
162
|
-
if vtype='N'
|
|
163
|
-
|
|
164
|
-
and cats(upcase(raw_value)) in (
|
|
170
|
+
if vtype='N' & OPERATOR_NM in ('=','>','<','<=','>=','NE','GE','LE') then do;
|
|
171
|
+
if cats(upcase(raw_value)) in (
|
|
165
172
|
'.','.A','.B','.C','.D','.E','.F','.G','.H','.I','.J','.K','.L','.M','.N'
|
|
166
173
|
'.N','.O','.P','.Q','.R','.S','.T','.U','.V','.W','.X','.Y','.Z','._'
|
|
167
174
|
)
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
175
|
+
then do;
|
|
176
|
+
/* valid numeric - exit data step loop */
|
|
177
|
+
return;
|
|
178
|
+
end;
|
|
179
|
+
else if subpad(upcase(raw_value),1,1) in (
|
|
180
|
+
'A','B','C','D','E','F','G','H','I','J','K','L','M','N'
|
|
181
|
+
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z','_'
|
|
182
|
+
)
|
|
183
|
+
then do;
|
|
184
|
+
/* check if the raw_value contains a valid variable NAME */
|
|
185
|
+
vnum=varnum(dsid,subpad(raw_value,1,32));
|
|
186
|
+
if vnum>0 then do;
|
|
187
|
+
/* now we can get the type */
|
|
188
|
+
vtype2=vartype(dsid,vnum);
|
|
189
|
+
/* check type matches */
|
|
190
|
+
if vtype2=vtype then do;
|
|
191
|
+
/* valid target var - exit loop */
|
|
192
|
+
return;
|
|
193
|
+
end;
|
|
194
|
+
else do;
|
|
195
|
+
REASON_CD=cats("Compared Type (",vtype2,") is not (",vtype,")");
|
|
196
|
+
putlog REASON_CD= dsid=;
|
|
197
|
+
call symputx('reason_cd',reason_cd,'l');
|
|
198
|
+
call symputx('nobs',_n_,'l');
|
|
199
|
+
output;
|
|
200
|
+
goto endstep;
|
|
201
|
+
end;
|
|
202
|
+
end;
|
|
203
|
+
end;
|
|
171
204
|
end;
|
|
172
205
|
|
|
173
206
|
/* special logic */
|
|
@@ -189,6 +222,32 @@ data &outds;
|
|
|
189
222
|
if vtype='N' then do i=1 to countc(raw_value1, ',')+1;
|
|
190
223
|
tmp=scan(raw_value1,i,',');
|
|
191
224
|
if cats(tmp) ne '.' and input(tmp, ?? 8.) eq . then do;
|
|
225
|
+
if OPERATOR_NM ='BETWEEN' and subpad(upcase(tmp),1,1) in (
|
|
226
|
+
'A','B','C','D','E','F','G','H','I','J','K','L','M','N'
|
|
227
|
+
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z','_'
|
|
228
|
+
)
|
|
229
|
+
then do;
|
|
230
|
+
/* check if the raw_value contains a valid variable NAME */
|
|
231
|
+
/* is not valid syntax for IN or NOT IN */
|
|
232
|
+
vnum=varnum(dsid,subpad(tmp,1,32));
|
|
233
|
+
if vnum>0 then do;
|
|
234
|
+
/* now we can get the type */
|
|
235
|
+
vtype2=vartype(dsid,vnum);
|
|
236
|
+
/* check type matches */
|
|
237
|
+
if vtype2=vtype then do;
|
|
238
|
+
/* valid target var - exit loop */
|
|
239
|
+
return;
|
|
240
|
+
end;
|
|
241
|
+
else do;
|
|
242
|
+
REASON_CD=cats("Compared Type (",vtype2,") is not (",vtype,")");
|
|
243
|
+
putlog REASON_CD= dsid=;
|
|
244
|
+
call symputx('reason_cd',reason_cd,'l');
|
|
245
|
+
call symputx('nobs',_n_,'l');
|
|
246
|
+
output;
|
|
247
|
+
goto endstep;
|
|
248
|
+
end;
|
|
249
|
+
end;
|
|
250
|
+
end;
|
|
192
251
|
REASON_CD='Non Numeric value provided';
|
|
193
252
|
putlog REASON_CD= OPERATOR_NM= raw_value= raw_value1= ;
|
|
194
253
|
call symputx('reason_cd',reason_cd,'l');
|
|
@@ -213,14 +272,42 @@ data &outds;
|
|
|
213
272
|
|
|
214
273
|
/* output records that contain values other than digits and spaces */
|
|
215
274
|
if notdigit(compress(raw_value3,' '))>0 then do;
|
|
275
|
+
if vtype='C' and subpad(upcase(raw_value),1,1) in (
|
|
276
|
+
'A','B','C','D','E','F','G','H','I','J','K','L','M','N'
|
|
277
|
+
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z','_'
|
|
278
|
+
)
|
|
279
|
+
then do;
|
|
280
|
+
/* check if the raw_value contains a valid variable NAME */
|
|
281
|
+
vnum=varnum(dsid,subpad(raw_value,1,32));
|
|
282
|
+
if vnum>0 then do;
|
|
283
|
+
/* now we can get the type */
|
|
284
|
+
vtype2=vartype(dsid,vnum);
|
|
285
|
+
/* check type matches */
|
|
286
|
+
if vtype2=vtype then do;
|
|
287
|
+
/* valid target var - exit loop */
|
|
288
|
+
return;
|
|
289
|
+
end;
|
|
290
|
+
else do;
|
|
291
|
+
REASON_CD=cats("Compared Char Type (",vtype2,") is not (",vtype,")");
|
|
292
|
+
putlog REASON_CD= dsid=;
|
|
293
|
+
call symputx('reason_cd',reason_cd,'l');
|
|
294
|
+
call symputx('nobs',_n_,'l');
|
|
295
|
+
output;
|
|
296
|
+
goto endstep;
|
|
297
|
+
end;
|
|
298
|
+
end;
|
|
299
|
+
end;
|
|
300
|
+
|
|
216
301
|
putlog raw_value3= $hex32.;
|
|
217
302
|
REASON_CD=cats('Invalid RAW_VALUE:',raw_value);
|
|
218
|
-
putlog
|
|
303
|
+
putlog (_all_)(=);
|
|
219
304
|
call symputx('reason_cd',reason_cd,'l');
|
|
220
305
|
call symputx('nobs',_n_,'l');
|
|
221
306
|
output;
|
|
222
307
|
end;
|
|
223
308
|
|
|
309
|
+
endstep:
|
|
310
|
+
if last then rc=close(dsid);
|
|
224
311
|
run;
|
|
225
312
|
|
|
226
313
|
|
package/package.json
CHANGED