Dear all,
I faced a problem while using reshape command for my data.
reshape wide time_from time_to, i(pid) j(hhid)
(note: j = 1000101)
values of variable hhid not unique within pid
Your data are currently long. You are performing a reshape wide. You specified i(pid)
and j(hhid). There are observations within i(pid) with the same value of j(hhid). In
the long data, variables i() and j() together must uniquely identify the observations.
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 |
+---------------+
Type reshape error for a list of the problem variables.
r(9);
My dataset looks something like this
time_from time_to hhid pid
06:30 07:00 1000101 1000101002
17:00 18:30 1000101 1000101002
18:30 19:00 1000101 1000101003
19:00 20:00 1000101 1000101003
21:30 04:00 1000101 1000101004
09:00 10:00 1000101 1000101004
04:00 06:30 1000102 1000102001
16:00 16:30 1000102 1000102001
21:00 21:30 1000103 1000103001
06:00 06:30 1000103 1000103001
21:30 04:00 1000103 1000103002
18:30 19:00 1000103 1000103002
here, (pid) is the unique identifier in a household(hhid) but its observation is repeated because the same person's data is collected over time in a day. when I used the command
reshape wide time_from time_to, i(pid) j(hhid)
it says "values of variable hhid not unique within pid"
how can I generate a unique id for such a dataset? or how can I reshape such dataset from long to wide?
ThankYou all in advance for the help.
Related Posts with Reshaping long to wide data with multiple unique identifier in a data set
Impulse response functions for threshold ARmaX ModelsI have an ARmaX model that I need to estimate using threshold regressions (i.e "threshold" command )…
setstars function using asdocDear Statalist Users, I am using the wonderful installation package asdoc and I am very grateful, t…
Use an estimated coefficient as independent variableDear Stata community, I have a panel dataset at the regional level for a set of 10 countries (i.e s…
Line graph for frequency distribution by categorical variableHi Statalist, I would like to create a line graph showing frequency (percent) distribution of a giv…
Random effects term for mother - help with some codeHi, I'm using inverse probability treatment weighting for the propensity for vaccination, followed b…
Subscribe to:
Post Comments (Atom)
0 Response to Reshaping long to wide data with multiple unique identifier in a data set
Post a Comment