Hello everyone,
I was wondering if anyone would be able to help me understand what I may be doing wrong with my ID variables, I would like to reshape my dataset from wide to long.
I have a panel dataset with 4 waves (but I'm only wanting to use waves 3 and 4, each wave has a person variable and a case/household variable. I merged the two waves using these person and case variables.
I have attached a screenshot of a section of what these variables look like:
Household ID variables.tiff Person ID variables.tiff
I then created one ID variable:
egen personID = group(person household)
And finally tried to reshape using this:
reshape long PresyrW PresmonW TypeW sexw DVGIEMPw PermJbW EmpStYW EdLevelW DVHasDCW PFTyp1W POMeth1W POEmFr1W ORetIncW OriskaW OriskcW OSaferetW OunderW OPenSavW DVAge9W PDCVal1W SpendMW LvTdayW, i(personID) j(wave)
When I try and reshape the dataset I get the error (r(9)) says that my variable ID does not uniquely identify the observations.
I was wondering how I might deal with duplicates in my ID variable or how to generate one that doesn't contain duplicates so that I am able to reshape.
Any help is greatly appreciated, thanks,
Alice
I was wondering if anyone would be able to help me understand what I may be doing wrong with my ID variables, I would like to reshape my dataset from wide to long.
I have a panel dataset with 4 waves (but I'm only wanting to use waves 3 and 4, each wave has a person variable and a case/household variable. I merged the two waves using these person and case variables.
I have attached a screenshot of a section of what these variables look like:
Household ID variables.tiff Person ID variables.tiff
I then created one ID variable:
egen personID = group(person household)
And finally tried to reshape using this:
reshape long PresyrW PresmonW TypeW sexw DVGIEMPw PermJbW EmpStYW EdLevelW DVHasDCW PFTyp1W POMeth1W POEmFr1W ORetIncW OriskaW OriskcW OSaferetW OunderW OPenSavW DVAge9W PDCVal1W SpendMW LvTdayW, i(personID) j(wave)
When I try and reshape the dataset I get the error (r(9)) says that my variable ID does not uniquely identify the observations.
I was wondering how I might deal with duplicates in my ID variable or how to generate one that doesn't contain duplicates so that I am able to reshape.
Any help is greatly appreciated, thanks,
Alice
Comment