BookmarkSubscribeRSS Feed
JuanVte
Calcite | Level 5
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.
2 REPLIES 2
S_E_N_T_H_I_L
Calcite | Level 5
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
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1379 views
  • 0 likes
  • 3 in conversation