1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-14 20:10:05 +00:00

feat: new mp_applyformats macro (and test), plus new addition to mp_validatecol (is_format)

This commit is contained in:
munja
2021-12-23 13:50:58 +00:00
parent a13c782074
commit 9f815c73e9
6 changed files with 281 additions and 3 deletions

View File

@@ -20,10 +20,13 @@
;;;;
run;
Tip - when contributing, use https://regex101.com to test the regex validity!
@param [in] incol The column to be validated
@param [in] rule The rule to apply. Current rules:
@li ISNUM - checks if the variable is numeric
@li LIBDS - matches LIBREF.DATASET format
@li FORMAT - checks if the provided format is syntactically valid
@param [out] outcol The variable to create, with the results of the match
<h4> SAS Macros </h4>
@@ -62,5 +65,19 @@
if prxmatch(&tempcol, trim(&incol)) then &outcol=1;
else &outcol=0;
%end;
%else %if &rule=FORMAT %then %do;
/* match valid format - regex could probably be improved */
if _n_=1 then do;
retain &tempcol;
&tempcol=prxparse('/^[_a-z\$]\w{0,31}\.[0-9]*$/i');
if missing(&tempcol) then do;
putlog "%str(ERR)OR: Invalid expression for FORMAT";
stop;
end;
drop &tempcol;
end;
if prxmatch(&tempcol, trim(&incol)) then &outcol=1;
else &outcol=0;
%end;
%mend mp_validatecol;