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
Determining Causal Relationship using instrumental variableI have used the "xtivreg" command to account for endogeneity (My IV is Deviation from Average Rainfa…
Long to WideHey, I have a long dataset that I want to convert to wide which looks like below. I've been reading…
Significance at 5% or 10% for a regression outputDear Stata Members I would like to ask a question on interpreting the significance of results based…
Creating a categorical variable with several conditionsDear all, I am a STATA-beginner and am currently struggling with creating a categorical variable tha…
Calculate gini coefficients for each groups of a datasetHello, I want to calculate ginicoefficients for each group of a dataset. The table shows an example…
Subscribe to:
Post Comments (Atom)
0 Response to Reshaping long to wide data with multiple unique identifier in a data set
Post a Comment