I am looking to reshape
this long
dataset into a wide
one. The reshaping will be done with fartyid
as my unique ID conditional on landingsdato
, meaning that a new observation will be made up of all fartyID
who share landingsdato
. Most of my variables not included here can be collapsed without any further considerations, as, conditional on these two, they will hold the same values for every observation.
The problem are the categorical variables included here (artkode
, produkttilstandkode
and strrelsesgruppering
) which I'd like to keep all information on, in a generalized way so that I can work with them for the whole dataset. produkvekt
is a numerical variable which denotes the quantity of artkode
.
fartyid landingsdato artkode artbokml produkttilstandkode strrelsesgruppering produktvekt
1926005936 01.03.2004 1032 Sei 211 4023999 20
1926005936 01.03.2004 1032 Sei 211 4012023 14
1926005936 01.03.2004 102201 Skrei 641 3000000 55
1926005936 01.03.2004 102201 Skrei 642 3000000 60
1926005936 01.03.2004 102201 Skrei 211 4010025 60
1926005936 01.03.2004 102201 Skrei 211 4025999 500
I can't wrap my head around how this should be done, if it's possible at all, so I am grateful for all input.
Unique values for categorical variables:
strrelsesgruppering: 457
produkttilstandkode: 53
artkode: 149
As an example of how I might wind up:
fartyid landingsdato 1032 produkttilstandkode strrelsesgruppering produktvekt
1926005936 01.03.2004 1 211 4023999 20
And then the subsequent artkode
lined up along the row, but this would give me problems when working with the dataset as I'd have several of the same artkode
in different columns.
I can't wrap my head around how this should be done if it's possible at all.
wide
structure? These are in good condition for most Stata operations. What calculations make you think you require areshape
? – Nick Cox