Announcement

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

  • Append two datasets: Same var names but different var labels

    Dear Stata Community,

    I want to append two datasets each having different number of variables. For append, it is important that var names should be similar in both datasets to properly append the information associated with each variable. but there is a problem. I imported sheets into Stata such that each variable got its name based on the first row of excel. However, some variables got the names not based on the first row but from Excel Column number such as AI, BI, CI etc. Now, when appending with the second data, it is problematic. Because in the second data also there are variables which got names from Excel column such as AI, BI, CI however, these columns now has different information and the label is different. This is because the number of variables are different in each dataset.

    For example:
    Data 1: Data 2:
    Month AI BI CI Month BI CI DI
    Yes Jan Feb Mar Yes Jan Feb Mar

    I have tried many methods but have not find any efficient solution yet. To mention, each dataset contains almost 600 variables that are not carrying excel row label. This gives me tough time. Is there any way you can suggest to deal with it efficiently?

    Thanks

  • #2
    Do all excel files/sheers have variable names? If so, I would focus on importing the sheets correctly with their variable names and not the excel column names. See help import excel. You may need to to use the cellrange and firstrow options, or even clean/unify the sheets first.

    Comment

    Working...
    X