Hi, I asked this question in Cross Validated but they requested I move it here,
I have a dataset of the form:
YEAR ID Data
year X 1 x_1
year X 2 x_2
year Y 1 y_1
year Y 2 y_2
...
I would like to put it in the form:
YEAR ID Data_X Data_Y
year 1 x_1 y_1
year 2 x_2 y_2
...
I feel like we want to make vectors somehow out of the years $X$ and $Y$, so that here the data set becomes a $2 \times 1$ vector, then take the transpose of it.
A comment as an answer there said to use "dcast" in R, is there any equivalent command for this in Stata?
I have a dataset of the form:
YEAR ID Data
year X 1 x_1
year X 2 x_2
year Y 1 y_1
year Y 2 y_2
...
I would like to put it in the form:
YEAR ID Data_X Data_Y
year 1 x_1 y_1
year 2 x_2 y_2
...
I feel like we want to make vectors somehow out of the years $X$ and $Y$, so that here the data set becomes a $2 \times 1$ vector, then take the transpose of it.
A comment as an answer there said to use "dcast" in R, is there any equivalent command for this in Stata?
Comment