BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
eagles_dare13
Obsidian | Level 7

When I write:

%let x = 0.32;

How can I make sure that x is initialized as a numeric variable and not a character variable? I want to be able to do numerical operations on x.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You can perform numerical calcuations to create additional MACRO variable values using the %sysfunc or %eval<integers only> or %sysevalf.

 

%let x = 0.32;

%let y = %sysevalf(&x * 6.2);

%let z = %sysfunc( max(&x,&y,23));

%put y= &y z= &z;

If the idea is to do numeric operations in a data step then your X variable would be treated and used as a constant value.

View solution in original post

2 REPLIES 2
jakarman
Barite | Level 11

macro variables are always text based as the goal is modify the sas source code.

In normal situations numerical calculations are exceptional in a sas macro as they are processed within a sas-datastep.

Are you sure you are not mixing up some goals of the several different coding languages within a SAS environment?     

---->-- ja karman --<-----
ballardw
Super User

You can perform numerical calcuations to create additional MACRO variable values using the %sysfunc or %eval<integers only> or %sysevalf.

 

%let x = 0.32;

%let y = %sysevalf(&x * 6.2);

%let z = %sysfunc( max(&x,&y,23));

%put y= &y z= &z;

If the idea is to do numeric operations in a data step then your X variable would be treated and used as a constant value.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

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