Hello, I'm rather new to Stata. I'm having an issue reshaping my data from wide to long. This is what my data currently looks like:
I would like it to look like this:
This is the code I've been attempting:
This is the error Stata returns:
Hopefully you can help! Thanks.
Jacob
subject | condai | condap | condpi | condpp |
1 | 0.6 | 0.4 | 0.2 | 0.1 |
2 | 0.3 | 0.7 | 0.2 | 0.4 |
3 | 0.2 | 0.7 | 0.2 | 0.1 |
I would like it to look like this:
subject | cond | value |
1 | ai | 0.6 |
1 | ap | 0.4 |
1 | pi | 0.2 |
1 | pp | 0.1 |
2 | ai | 0.3 |
2 | ap | 0.7 |
2 | pi | 0.2 |
2 | pp | 0.4 |
3 | ai | 0.2 |
3 | ap | 0.7 |
1 | pi | 0.2 |
1 | pp | 0.1 |
This is the code I've been attempting:
Code:
. reshape long cond i(subject) j(cond)
Code:
option i() required long wide +---------------+ +------------------+ | i j a b | | i a1 a2 b1 b2 | |---------------| <--- reshape ---> |------------------| | 1 1 1 2 | | 1 1 3 2 4 | | 1 2 3 4 | | 2 5 7 6 8 | | 2 1 5 6 | +------------------+ | 2 2 7 8 | +---------------+ long to wide: reshape wide a b, i(i) j(j) (j existing variable) wide to long: reshape long a b, i(i) j(j) (j new variable)
Jacob
Comment