mirror of
https://github.com/sasjs/core.git
synced 2026-04-11 19:03:13 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b74caede4 |
16
all.sas
16
all.sas
@@ -14541,7 +14541,7 @@ alter table &libds modify &var char(&len);
|
|||||||
%mend mp_updatevarlength;
|
%mend mp_updatevarlength;
|
||||||
/**
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Used to validate values in a data step
|
@brief Used to validate variables in a dataset
|
||||||
@details Useful when sanitising inputs, to ensure that they arrive with a
|
@details Useful when sanitising inputs, to ensure that they arrive with a
|
||||||
certain pattern.
|
certain pattern.
|
||||||
Usage:
|
Usage:
|
||||||
@@ -14568,7 +14568,6 @@ alter table &libds modify &var char(&len);
|
|||||||
@param [in] incol The column to be validated
|
@param [in] incol The column to be validated
|
||||||
@param [in] rule The rule to apply. Current rules:
|
@param [in] rule The rule to apply. Current rules:
|
||||||
@li ISINT - checks if the variable is an integer
|
@li ISINT - checks if the variable is an integer
|
||||||
@li ISLIB - checks if the value is a valid libref (NOT whether it exists)
|
|
||||||
@li ISNUM - checks if the variable is numeric
|
@li ISNUM - checks if the variable is numeric
|
||||||
@li LIBDS - matches LIBREF.DATASET format
|
@li LIBDS - matches LIBREF.DATASET format
|
||||||
@li FORMAT - checks if the provided format is syntactically valid
|
@li FORMAT - checks if the provided format is syntactically valid
|
||||||
@@ -14607,19 +14606,6 @@ alter table &libds modify &var char(&len);
|
|||||||
else &outcol=1;
|
else &outcol=1;
|
||||||
drop &tempcol;
|
drop &tempcol;
|
||||||
%end;
|
%end;
|
||||||
%else %if &rule=ISLIB %then %do;
|
|
||||||
if _n_=1 then do;
|
|
||||||
retain &tempcol;
|
|
||||||
&tempcol=prxparse('/^[_a-z]\w{0,7}$/i');
|
|
||||||
if missing(&tempcol) then do;
|
|
||||||
putlog 'ERR' +(-1) "OR: Invalid expression for ISLIB";
|
|
||||||
stop;
|
|
||||||
end;
|
|
||||||
drop &tempcol;
|
|
||||||
end;
|
|
||||||
if prxmatch(&tempcol, trim(&incol)) then &outcol=1;
|
|
||||||
else &outcol=0;
|
|
||||||
%end;
|
|
||||||
%else %if &rule=LIBDS %then %do;
|
%else %if &rule=LIBDS %then %do;
|
||||||
/* match libref.dataset */
|
/* match libref.dataset */
|
||||||
if _n_=1 then do;
|
if _n_=1 then do;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Used to validate values in a data step
|
@brief Used to validate variables in a dataset
|
||||||
@details Useful when sanitising inputs, to ensure that they arrive with a
|
@details Useful when sanitising inputs, to ensure that they arrive with a
|
||||||
certain pattern.
|
certain pattern.
|
||||||
Usage:
|
Usage:
|
||||||
@@ -27,7 +27,6 @@
|
|||||||
@param [in] incol The column to be validated
|
@param [in] incol The column to be validated
|
||||||
@param [in] rule The rule to apply. Current rules:
|
@param [in] rule The rule to apply. Current rules:
|
||||||
@li ISINT - checks if the variable is an integer
|
@li ISINT - checks if the variable is an integer
|
||||||
@li ISLIB - checks if the value is a valid libref (NOT whether it exists)
|
|
||||||
@li ISNUM - checks if the variable is numeric
|
@li ISNUM - checks if the variable is numeric
|
||||||
@li LIBDS - matches LIBREF.DATASET format
|
@li LIBDS - matches LIBREF.DATASET format
|
||||||
@li FORMAT - checks if the provided format is syntactically valid
|
@li FORMAT - checks if the provided format is syntactically valid
|
||||||
@@ -66,19 +65,6 @@
|
|||||||
else &outcol=1;
|
else &outcol=1;
|
||||||
drop &tempcol;
|
drop &tempcol;
|
||||||
%end;
|
%end;
|
||||||
%else %if &rule=ISLIB %then %do;
|
|
||||||
if _n_=1 then do;
|
|
||||||
retain &tempcol;
|
|
||||||
&tempcol=prxparse('/^[_a-z]\w{0,7}$/i');
|
|
||||||
if missing(&tempcol) then do;
|
|
||||||
putlog 'ERR' +(-1) "OR: Invalid expression for ISLIB";
|
|
||||||
stop;
|
|
||||||
end;
|
|
||||||
drop &tempcol;
|
|
||||||
end;
|
|
||||||
if prxmatch(&tempcol, trim(&incol)) then &outcol=1;
|
|
||||||
else &outcol=0;
|
|
||||||
%end;
|
|
||||||
%else %if &rule=LIBDS %then %do;
|
%else %if &rule=LIBDS %then %do;
|
||||||
/* match libref.dataset */
|
/* match libref.dataset */
|
||||||
if _n_=1 then do;
|
if _n_=1 then do;
|
||||||
|
|||||||
@@ -129,30 +129,4 @@ run;
|
|||||||
desc=Test4 - ISFORMAT,
|
desc=Test4 - ISFORMAT,
|
||||||
test=EQUALS 6,
|
test=EQUALS 6,
|
||||||
outds=work.test_results
|
outds=work.test_results
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test 5 - ISLIB
|
|
||||||
*/
|
|
||||||
data test5;
|
|
||||||
infile datalines4 dsd;
|
|
||||||
input;
|
|
||||||
inf=_infile_;
|
|
||||||
%mp_validatecol(inf,ISLIB,islib)
|
|
||||||
if islib=1;
|
|
||||||
datalines4;
|
|
||||||
some
|
|
||||||
!lib
|
|
||||||
%abort
|
|
||||||
definite
|
|
||||||
2fail
|
|
||||||
nineletrs
|
|
||||||
.failalso
|
|
||||||
_valid
|
|
||||||
;;;;
|
|
||||||
run;
|
|
||||||
%mp_assertdsobs(work.test5,
|
|
||||||
desc=Testing ISLIB,
|
|
||||||
test=EQUALS 3,
|
|
||||||
outds=work.test_results
|
|
||||||
)
|
)
|
||||||
Reference in New Issue
Block a user