Violet_09, First, let's worry about generating the proper names. Then we can worry about how to incorporate them into your program. Please correct any of this if it is wrong. It looks like you are starting with two macro variables: &ENDING_YEAR (which contains 4 digits) and &ENDING_MONTH (which contains two digits). Based on that, you need to generate a name that represents the prior month. (Perhaps you need to generate a set of names representing a range of months, but your post doesn't make that clear.) That's relatively easy for a DATA step to do. For example: data test; current_month = mdy(&ending_month, 1, &ending_year); name1 = cats('cbalance_', put(current_month,monname.), '_', put(current_month,year4.)); prior_month = current_month - 1; name2 = cats('cbalance_', put(prior_month,monname.), '_', put(prior_month,year4.)); run; Do NAME1 and NAME2 contain exactly what you are looking for? Do you need additional names (since it does look like the original macro contained a few loops)? If NAME1 and NAME2 are correct, how should they be used in your program? Apologies if there are any errors in the code, but I'm not in a position to test this right now. Good luck.
... View more