Hi everyone,

Thanks for what you do, I have benefited from your discussions for a long time before registering.
I will try to be as clear as I can, any advice about the form or contents of future posts are more than welcome.

I am working with a very messy dataset extracted from PSID. I know there exists a package by Prof. Kohler about it but I am not able to use it at the current state. I have a wide form dataset with cyclically repeated variables: to exemplify it, let's say that I have an ID variable for each family as the first vector and after that a set of N variables for each year. N is NOT constant throughout the years. Therefore, we will see all families with N variables for year 1968 (first), with N+2 variables for 1969, etc...
The structure would be like this:

ID | A // B // C | D // E // F // G | ....

Notice than A-D, B-E, C-F are the SAME variables, but with different names.

What I need is to eventually use a reshape of the following form:
Code:
reshape long **ReadyData**, i(ID) j(year)
My first (clumsy) attempt has been to use a loop I have been using in a similar situation, where I created a list and extracted some strings and attached them to the new name I wanted to set. As follows:
Code:
ds, has (varl *INTERVIEW*) 
foreach v of var `r(varlist)' {
         local label : var label `v'
         local newlabel = substr(`"`label'"', 1, 4)
         rename `v' ER_`newlabel'
}
The problem is that I need to select the year from the first variable of the list
Code:
ds, has (varl *INTERVIEW*)
, and attach it to every variable A B C. Then I need the loop to switch to the second variable, selecting the second year, and attach it to D E F G, and so on. My attempts to nesting loops have failed so far. If you could help me out with this I would be very grateful.
Many thanks,

Francesco