Dear Statalist community,

I fear this might be a simple question but I am having trouble finding an effective way of transforming my dataset from wide form to long form.

My variables come from a panel dataset where the prefix cw08a and cw09b signify the year each question was asked, the suffix, which range from 001 to 525 indicate the question asked to individuals. I have been trying to reshape the data using my i variable which define the individual (nomem_encr). I am pretty sure that the code should look something like this:

Code:
reshape long 001-525 , i(nomem_encr) j(year)
However, I am don't know how exactly to code the stub 001-525 without doing in manually one at a time. I have included some data from dataex if this helps explain my query, including the variable cw08a_m and cwo9b_m provide the year and month each interview was held:

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input double(nomem_encr cw08a002 cw08a004 cw08a310 cw08a_m cw09b002 cw09b004 cw09b310 cw09b_m)
800033 1991 8 . 200804 1991 8 . 200904
800042 1975 5 . 200804 1975 6 . 200904
end
label values cw08a004 cw08a004
label def cw08a004 5 "5", modify
label def cw08a004 8 "8", modify
label values cw08a310 cw08a310
label values cw09b004 cw09b004
label def cw09b004 6 "6", modify
label def cw09b004 8 "8", modify
label values cw09b310 cw09b310
Thank you in advance,
Hugo