Announcement

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

  • Issue with Appending two datasets

    Hi all,

    I have 2 panel datasets, one for men and one for women, and I want to combine them together. So I used to Append option.

    However, when I use
    Code:
    xtreg, fe
    function for a fixed-effects model including the gender, the effect of gender got estimated, which is weird because it is supposed to be omitted due to the use of
    Code:
    xtreg, fe
    option. So I thought there might be some gender changes for some individuals, or it could be because of a genuine error from the data itself.

    So I went back to check the IDs for each sample to see if there was anyone with the same IDs but with a different gender. So I did it by taking the difference in IDs, if the difference is 0, then that ID appears in both samples. However, it turns out that none of the differences are 0. Each sample has a different set of IDs, which means no one changes their gender over time or has no errors.

    So I think i have done something wrong with the Append function, here is my code:

    Code:
    use men_data.dta, clear
    append using women_data.dta
    I do not think I got the codes wrong but my blood is boiling at the moment because my 2-cell brain could not figure out why gender got estimated in the fixed-effect model.

    Could anyone please let me know if I am doing something wrong :<

    Thank you.

  • #2
    Originally posted by Duy To View Post
    . . . I went back to check the IDs for each sample to see if there was anyone with the same IDs but with a different gender. So I did it by taking the difference in IDs, if the difference is 0, then that ID appears in both samples.
    I don't quite follow what you did there, but couldn't you do something like this?
    Code:
    sysuse auto
    bysort rep78 (foreign): generate byte dif = foreign[_N] != foreign[1]
    list rep78 foreign dif, noobs sepby(rep78)

    Comment


    • #3
      Hi Joseph,

      Thank you for your suggestion, I do not know about those codes.

      The way that I did it is I copied the IDs from the male sample, I copied the IDs from the female sample, and then I compared those 2 sets of IDs to see if there were any IDs that appeared in both samples. And I see that no IDs appear in the samples, which means that the gender for each ID does not change over time. That is why I do not know why I got the coefficients for gender in the fixed-effects model because it is not supposed to be there if the gender is fixed over time.

      Comment


      • #4
        Originally posted by Duy To View Post
        . . . no IDs appear in the samples, which means that the gender for each ID does not change over time.
        Apparently not so from what xtreg , fe is telling you.

        I assume that the two datasets have a variable for sex. Try either my code above mutatis mutandis or something the the following.
        Code:
        use men_data.dta, clear
        assert sex == sex[1]
        use women_data.dta, clear
        assert sex == sex[1]

        Comment


        • #5
          it turns out my 2-cell brain really has only 2 cells. Everything is sorted out, thank you everyone xoxo

          Comment

          Working...
          X