Hi all,
Glad to see all the spam posts gone- thank you admins!
I am trying to merge/append two datasets with the same households (identified by hhcode) with individual data. The individuals belong to the different households and are identified by hhcode but also by their individual number Personnalnumber.
Master data:
Data to append:
I basically want to fill in the missing values in the master data (medexp: medical expenditures) and duplicate the observations if there are many members in the family (accounted for with the Personnalnumber variable).
I think the -merge- command is useless here since I'm not adding any new variables. However, if I use the -append- command, Stata properly appends the data but it just "adds" the observations at the end of the dataset, does not fill in the missing values.
I don't know how to tell Stata do fill in those missing values and to duplicate observations to the multiple members of the family. I think it would be a mix between merging and appending. Is there any way to do that?
On another note: I apologize because I've been posting questions every couple of days recently...
Glad to see all the spam posts gone- thank you admins!
I am trying to merge/append two datasets with the same households (identified by hhcode) with individual data. The individuals belong to the different households and are identified by hhcode but also by their individual number Personnalnumber.
Master data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int hhcode long(Personnalnumber medexp) 1005 100501 . 1014 101401 . 1025 102501 . 1025 102502 . 1031 103101 . 1031 103102 . 1031 103103 . 1031 103104 . 1033 103301 . 1033 103302 . 1035 103501 . 1039 103901 . 1039 103902 . 1039 103903 . 1052 105201 . 1053 105301 . 1057 105701 . 1058 105801 . 1058 105802 . 1058 105803 . 1058 105804 . 1061 106101 . 1061 106102 . 1063 106301 . end
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int hhcode long medexp 1005 300 1014 200 1025 2000 1031 4000 1033 650 1035 1000 1039 2150 1052 0 1053 200 1057 500 1058 0 1061 0 1063 1000 end
I think the -merge- command is useless here since I'm not adding any new variables. However, if I use the -append- command, Stata properly appends the data but it just "adds" the observations at the end of the dataset, does not fill in the missing values.
I don't know how to tell Stata do fill in those missing values and to duplicate observations to the multiple members of the family. I think it would be a mix between merging and appending. Is there any way to do that?
On another note: I apologize because I've been posting questions every couple of days recently...
Comment