Announcement

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

  • Merging multiple Spss data sets into STATA

    Hi, I'm trying to merge a few UNICEF MICS survey data files together which are on Spss onto stata, for example file ch.sav with hh.sav. I have them all saved as individual STATA files. Can somebody help with the correct command please as nothing I'm trying is working!

  • #2
    There are two aspects to your process, translating the files from SPSS format to Stata format, and performing the merge in Stata. Your description doesn't give information that would enable us to tell where you are having a problem. You need to show us exactly what Stata commands you are using, and exactly what response you are getting from Stata, and what about it is "not working." None of us can guess what commands you tried and what particular errors they contained, and "not working" could mean hundreds of different things. Consequently, we can't help you. You will likely have much better luck getting an answer here if you re-read the relevant part of the StataList FAQ and use its advice to help you post a question so that it might be answered. With the right information in hand, solving your problem should be relatively easy.

    Comment


    • #3
      I have imported and saved the Spss files into STATA 16, I now need to merge the two STATA data sets:

      command:
      merge ch.sav hh.sav

      result:
      (note: you are using old merge syntax; see [D] merge for new syntax)
      factor-variable and time-series operators not allowed
      r(101);

      Comment


      • #4
        help merge
        First you need to open one dataset with Stata. I assume you have both data sets in .dta format. Then you need to specify the directory as well.

        If you want to merge many variables based on the year and wave. Example:

        merge m:m year wave using "C:\Users\youruser\Desktop\Mydata\chdata.dta"
        If there is only one variable that you want to merge from one dataset to the other:

        merge 1:1 variable using "C:\Users\youruser\Desktop\Mydata\chdata.dta"
        Make sure that both datasets have the same name for the variabels to be merged.

        Best,

        Comment


        • #5
          If you have converted the files why do they still have .sav extensions? I suspect you are not showing us what you really typed.

          m:m merges are strongly discouraged -- indeed, Stata indicates they should probably never be used.

          Read the help for merge or, possibly, append. Do these data sets have different variables but the same cases? Or do they have different cases, same variables? If the latter append may be the way to go.
          -------------------------------------------
          Richard Williams, Notre Dame Dept of Sociology
          StataNow Version: 19.5 MP (2 processor)

          EMAIL: [email protected]
          WWW: https://www3.nd.edu/~rwilliam

          Comment


          • #6
            They are 2 data sets from the same MICS survey but have different weightings which is what confuses me about merging them. Also, I want all the variables in the data sets to be merged.

            Comment


            • #7
              Justine, why don't you check the help for merge, try it, and then get back to us if problems persist. Usually people want a 1:1 or m:1 merge but we don't know enough about the data sets to advise you.
              -------------------------------------------
              Richard Williams, Notre Dame Dept of Sociology
              StataNow Version: 19.5 MP (2 processor)

              EMAIL: [email protected]
              WWW: https://www3.nd.edu/~rwilliam

              Comment


              • #8
                Just underlining the spelling: instead of Spss and STATA, the correct spelling is exactly the opposite use of cases, i.e., SPSS and Stata, respectively.
                Best regards,

                Marcos

                Comment


                • #9
                  Just making wild guesses, the CH file may have data on children while the HH file may have data on households. There can be 0 or more children per household. Therefore you will match using household id. If you open the child file first, it will be a m:1 merge.

                  The different weights do not surprise me. You would use one set of weights if you were analyzing households, a different set of weights if you were analyzing children. If you merge like I suggest I think you would use the children's weight.

                  Again, though, I am making wild guesses. Unless someone who has worked with these data happened to read this thread, I don't think there is enough info to answer you.

                  Incidentally, codebooks often have detailed discussions of weights and when and how you should use them.
                  -------------------------------------------
                  Richard Williams, Notre Dame Dept of Sociology
                  StataNow Version: 19.5 MP (2 processor)

                  EMAIL: [email protected]
                  WWW: https://www3.nd.edu/~rwilliam

                  Comment


                  • #10
                    Originally posted by Marcos Almeida View Post
                    Just underlining the spelling: instead of Spss and STATA, the correct spelling is exactly the opposite use of cases, i.e., SPSS and Stata, respectively.
                    I'll also just add that SPSS seems like a red herring here. If the files are now in Stata format, it really doesn't matter that they were once SPSS. Except that the merge command in #3 apparently referred to the SPSS files, which would cause problems even if you were using the correct syntax.
                    -------------------------------------------
                    Richard Williams, Notre Dame Dept of Sociology
                    StataNow Version: 19.5 MP (2 processor)

                    EMAIL: [email protected]
                    WWW: https://www3.nd.edu/~rwilliam

                    Comment

                    Working...
                    X