Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Merging two datasets with different number of rows

    I have two datasets like:

    Dataset1:
    Code:
    HH   ID   Weight(kg)
     1    1     36
     1    2     25
     1    3     40
     2    4     56
     2    5     76
     2    6     45
     3    7     43
     3    8     63
    Dataset2:
    Code:
    HH     ID    Height(m)
     1      2      1.2
     2      5      1.6
     3      8      1.5
    Now I want to merge these two datasets for the common HH and ID. That is, after merging the datasets will be looked like:
    Code:
    HH    ID    Height(m)   Weight(kg)
    1      2     1.2              25
    2      5     1.6              76
    3      8     1.5              63
    How can I code to do this?
    Please help me out!








  • #2
    Code:
    use dataset1, clear
    merge 1:1 HH ID using dataset2, keep(match) nogenerate

    Comment

    Working...
    X