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.