Hi everyone,
I'm trying to reshape my dataset from wide to long, but am running into some issues. I'm using StataSE15 on Windows 7.
I imported it as:
The numericcols(_all) is to prevent Stata from importing everything as strings.
The current format is:
unit_id series_id b01-01-2016 ... b14-11-2017
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
... ... ... ...
1000 1
1000 2
1000 3
1000 4
1000 5
1000 6
1000 7
1000 8
Where unit_id stands for a firm (1000 total) and series_id stands for various equity observations such as stock price, it's daily data ranging from 01-01-2016 to 14-11-2017.
I want it to take this format:
unit_id date series_id(1) series_id(2) ... series_id(8)
1 01-01-2016
1 02-02-2016
... ...
1 14-11-2017
etc
I tried
but got the error:
"no xij variables found" r(111)
which says: error . . . . . . . . . . . . . . . . . . . . . . . . Return code 111
__________ not found
no variables defined
The variable does not exist. You may have mistyped the
variable's name.
But I'm pretty sure I have not mistyped anything.
I tried
Where the b refers to the b before each date. This gives a list of errors saying (note: b1012016 not found)
(note: b1022016 not found)
(note: b1022017 not found)
(note: b1032016 not found)
(note: b1032017 not found)
(note: b1042016 not found)
(note: b1052017 not found)
(note: b1062016 not found)
which I eventually have to press break on, otherwise the computer crashes.
Does anyone have any idea how to reshape my data? Please let me know!
I'm trying to reshape my dataset from wide to long, but am running into some issues. I'm using StataSE15 on Windows 7.
I imported it as:
Code:
import delimited "X:\My Documents\filename.csv", delimiter(";") varnames(1) case(lower) numericcols(_all)
The current format is:
unit_id series_id b01-01-2016 ... b14-11-2017
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
... ... ... ...
1000 1
1000 2
1000 3
1000 4
1000 5
1000 6
1000 7
1000 8
Where unit_id stands for a firm (1000 total) and series_id stands for various equity observations such as stock price, it's daily data ranging from 01-01-2016 to 14-11-2017.
I want it to take this format:
unit_id date series_id(1) series_id(2) ... series_id(8)
1 01-01-2016
1 02-02-2016
... ...
1 14-11-2017
etc
I tried
Code:
reshape long date, i(unit_id series_id) j(date)
"no xij variables found" r(111)
which says: error . . . . . . . . . . . . . . . . . . . . . . . . Return code 111
__________ not found
no variables defined
The variable does not exist. You may have mistyped the
variable's name.
But I'm pretty sure I have not mistyped anything.
I tried
Code:
reshape long b, i(unit_id series_id) j(date)
(note: b1022016 not found)
(note: b1022017 not found)
(note: b1032016 not found)
(note: b1032017 not found)
(note: b1042016 not found)
(note: b1052017 not found)
(note: b1062016 not found)
which I eventually have to press break on, otherwise the computer crashes.
Does anyone have any idea how to reshape my data? Please let me know!
Comment