## Macro for a changing value in a calculation

Solved
Frequent Contributor
Posts: 81

# Macro for a changing value in a calculation

Hi,

I want to use a different value (number) for my formula everytime. Is there a way I can write a simple macro eg:

newvar=(oldvar- 9) x var2

the number 9 will change to 3, 6, and different values?

Help

Thanks

Accepted Solutions
Solution
‎01-18-2016 04:22 PM
Super User
Posts: 23,354

## Re: Macro for a changing value in a calculation

Yes, is there any pattern to the changes though?

How do you plan to execute each of your values?

Are you creating new_var that needs to be unique for each value? If so, how is each identified?

Are you creating a new data set that needs to be unique for each value? If so, how is each data set identified?

The gist is create a macro variable..

%let constant=9;

newvar=(oldvar-&constant) * var2;

Change constant, run the data step and newvar will change.

All Replies
Solution
‎01-18-2016 04:22 PM
Super User
Posts: 23,354

## Re: Macro for a changing value in a calculation

Yes, is there any pattern to the changes though?

How do you plan to execute each of your values?

Are you creating new_var that needs to be unique for each value? If so, how is each identified?

Are you creating a new data set that needs to be unique for each value? If so, how is each data set identified?

The gist is create a macro variable..

%let constant=9;

newvar=(oldvar-&constant) * var2;

Change constant, run the data step and newvar will change.

🔒 This topic is solved and locked.