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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1041 views
  • 0 likes
  • 3 in conversation