@PaigeMiller Thank you, this makes sense - that dataset2 is being overwritten with the second iteration. Thank you for that helpful explanation. When I run your suggested code, I get 2 datasets, and each dataset has only 1 variable of interest, either age_2001 in one and age_2020 in the other. However, I wanted both of those variables in the same dataset. You are correct - I wanted to do the macro as a practice exercise and to save from writing out 15 extra lines of code (15 age categories for 2001 and 15 for 2020). But it sounds like skipping the macro on this is the way to go. Thank you again!
... View more