I've used the following developed macro's with good success
in the past. Hope this helps.
PROC FORMAT ;
VALUE $XXX '0'-'9' ='NUM' ;
RUN;
...
%*------------- ;
%MACRO NUMCHKS ;
%*------------- ;
CHK_FLAG='N';
DO X=1 TO LENGTH(<fieldname>);
IF PUT(SUBSTR(<fieldname>,X,1),$XXX.) NE 'NUM'
THEN DO;
CHK_FLAG='Y';
X=99;
END;
%*------------- ;
%MEND NUMCHKS ;
%*------------- ;
...
%NUMCHKS(<fieldname>);
/* ------------------- O R ------------------------*/
...
%LET DIGIT = ('0','1','2','3','4','5','6','7','8','9');
...
%*------------- ;
%MACRO VALIDITY ;
%*------------- ;
SIZE=LENGTH(COMPRESS(<fieldname>));
IF (SIZE GT 1)
THEN DO;
VALIDFLG='Y';
DO I = 1 TO SIZE;
IF NOT (SUBSTR(COMPRESS(<fieldname>),I,1)
EQ &DIGIT)
THEN DO;
VALIDFLG='N';
I=99;
END;
END;
ELSE VALIDFLG='N';
DROP I VALIDFLG ;
%*------------- ;
%MEND VALIDITY ;
%*------------- ;
...
%VALIDITY(<fieldname>);
...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.