Good morning,

I would like to reshape my data from wide to long. I have multiple variables within the dataset that I would like to do this for. Each variable has a different number of iterations, that is, one variable <breed> has four iterations, the variable <caontrol> has 7 iterations and so on. Please see the dataset provided below.

I have used the following command to create an id variable
gen id= _n
reshape long caontrol, i(id) j(seq)

Where "seq" is sequence
And that reshapes one variable.

But then also changes the <id> variable such that it cannot be used to reshape the other variables.

My main question is: Is there a way to reshape multiple variables with different iterations, using a single command? And if not, what would you recommend please?

Thank you in advance.




----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str2(breed1 breed3 breed4) byte(caontrol1 caontrol2 caontrol3 caontrol4 caontrol5 caontrol6 caontrol7 wildcon1 wildcon2 wildcon3)
"PB" "MB" "MB" 1 0 1 1 1 1 1 1 0 0
"MB" "MB" "MB" 0 1 0 0 0 0 0 0 1 1
"PB" "PB" "PB" 1 1 1 1 1 1 1 0 1 1
"PB" "MB" "MB" 1 1 0 0 0 0 0 0 1 1
"PB" "MB" "MB" 1 1 1 1 1 1 1 0 1 1
end