The SAS Output Delivery System and reporting techniques

Regular expressions applied to macros variables

Reply
Contributor
Posts: 43

Regular expressions applied to macros variables

Hi everyone,

I would like to validate that a macro variable contents a numeric value.

I can do that with regular expresion in a data step but I do not know the way to do it with a macro variable.

%let var = 123;
%is_numeric(var);

is_numeric should return true

%let var = abc;
%is_numeric(var);

is_numeric should return false.

Could somebody help me??

Thanks!!
sincerely, Juanvte.
Occasional Contributor
Posts: 6

Re: Regular expressions applied to macros variables

Hi Juanvte,

Hope I understood.

If it is correct, you can get it by SCAN & INDEX function.

In the INDEX, you search for (0123456789) if its falls then its numeric.

Please correct, if it is falls.

Regards,

S E N T H I L
Super Contributor
Super Contributor
Posts: 3,174

Re: Regular expressions applied to macros variables

Also, check the ANYxxxx functions which came about with SAS 9, such as ANYDIGIT. With macro language, you also must use %SYSFUNC along with the call function.

Scott Barry
SBBWorks, Inc.

SAS Language Reference: Dictionary, Using Functions and CALL Routines
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a001281551.htm
Ask a Question
Discussion stats
  • 2 replies
  • 128 views
  • 0 likes
  • 3 in conversation