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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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