Posts: 23


Hello team,


im having issues with macros


im looking for a macros program that changes the matches the date on the criteria that i define



nov 2016 = oct 2016

Dec 2016= nov 2016

jan 2017=nov 2016


i have a month column and a year column separately


month1 vol mont 2 vol
nov 10 dec 9
dec 10 nov 19
jan 9 oct 9
feb 11 sep 8


thanks in advances

Posts: 1,269

Re: Macros

Posted in reply to SASuserxx

Do you have the data in two separate datasets?

Super User
Posts: 23,683

Re: Macros

Posted in reply to SASuserxx

This appears to be a lookup requirement. Use a datastep merge, SQL join, or hash table. 

No macros needed. 


Either way, you need to provide more details on your question. 

Super User
Super User
Posts: 9,599

Re: Macros

Posted in reply to SASuserxx

Post example test data of a) what you have, in a datastep, b) what you want the output to look like.  Most operations utilising dates you will find, are easier with actual date variables rather than the parts.  For this issue, if you have a date then you can use the interval functions to move the date back one month:



Secondly, if you data actually looks like that supplied, then arrays would be used to process multiple variables, not macro.  

Super User
Posts: 10,211

Re: Macros

Posted in reply to SASuserxx

Before we talk about tools, you should invest more time in clearly specifying your data as it is now and your requirements (intended result(s)).

After the issue is clear, the right tool to solve the problem will emerge.

Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 4 replies
  • 5 in conversation