turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- macro variable calculation

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-09-2012 01:10 PM

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.

Accepted Solutions

Solution

07-09-2012
01:19 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to bigbigben

07-09-2012 01:19 PM

%let xx=5;

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

%put yy=&yy;

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

Haikuo

All Replies

Solution

07-09-2012
01:19 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to bigbigben

07-09-2012 01:19 PM

%let xx=5;

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

%put yy=&yy;

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

Haikuo

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Haikuo

07-09-2012 01:26 PM

Hi, Hai.Kuo:

Thanks for the input. It works.