SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Macro for a changing value in a calculation

Accepted Solution Solved
Reply
Contributor
Posts: 64
Accepted Solution

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: 17,737

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.

View solution in original post


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

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.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 238 views
  • 1 like
  • 2 in conversation