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

Hi, guys:

I try to take the division operation on macro variables, but it does not work. Can you give me some idea how to do it.

As a simple example, I have a variable, xx=5 and I want to generate yy that yy=1/xx=.2. Both variables are macro variables.

My code is the following

%let xx=5;

%let yy=1/%eval(&xx.);

%put &yy.;

The outcome is yy=0.

It seems to be the case that the division operation causing the trouble. I even tried %let zz=%eval(1/5). The outcome is still 0.

Thanks for your input.


1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

%let xx=5;

%let yy=%SYSEVALF(1/&xx);

%put yy=&yy;

%SYSEVALF will do floating, while %eval will only do integer.

Haikuo

View solution in original post

2 REPLIES 2
Haikuo
Onyx | Level 15

%let xx=5;

%let yy=%SYSEVALF(1/&xx);

%put yy=&yy;

%SYSEVALF will do floating, while %eval will only do integer.

Haikuo

bigbigben
Obsidian | Level 7

Hi, Hai.Kuo:

Thanks for the input. It works.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 53663 views
  • 6 likes
  • 2 in conversation