

The catch is just understanding macro arithmetic, which is strictly integer, e.g. The macro really does not need a nested loop, you can calculate the year and month from the variable number. %let months=jan feb mar apr may jun jul aug sep oct nov dec

If you want to do it with a macro, even though everybody seems to know better, here is a way: %macro changenames %let month=jan feb mar apr may jun jul aug sep oct nov dec Input dum VAR_1 VAR_2 VAR_3 VAR_4 VAR_5 VAR_6 I've tried rearranging the loop and am just stuck.
DOUBLE FOR LOOP IN R CODE
I've tried the code listed, and I know it is overwriting each variable name. For programming purposes, I need to cycle through the column names and rename each variable with a month/year format: rename VAR_1=var_jan_2010 and so forth. These columns have names that reflect the month from the start date (ie VAR_1 = variable recorded on Jan 2010, VAR_2 = variable recorded on Feb 2010, all the way to VAR_36 = variable recorded on Dec 2012). In the example below, I have a dataset with variables that increment in months, for 36 columns total. I'm hoping someone can give me a sample to work with, as I have been reading and experimenting to no avail. I am brand new to SAS programming, so forgive my ignorance on how do loops iterate.
