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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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