I want to create a loop to append multiple waves of panel data. Most vars appear in each wave, three additional vars only appear in 4 waves. Should I therefore create two separate loops to append the waves?

I understand when appending waves the vars names need to be the same. In the panel data I have, a prefix is added to each varname to reflect the wave (age in wave 1 is aage, year 2 is bage, year 3 is cage), and for appending the vars need to have the same name. So can we code the removal this prefix within the loop to append the waves? And if not, how would I go about coding this?

Using the source datafile I save the renaming vars to a temp datafile, then save the appending to a new datafile, right? Some clarity in the code on this would be appreciated.

Thank you in advance.