Announcement

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

  • Saving CSV files in Stata

    Hi,

    I am trying to save changes in a CSV file in STATA. I have imported the file, wrote the commands and then exported it.
    I have used the following commands:

    import delimited "/Users/vardanyang/Dropbox/Irish migration - NSV/Ellis Island/Distances_1.csv"
    split v1, destring
    rename v11 ID_A
    rename v12 First_Name_A
    rename v13 Last_Name_A
    rename v14 ID_B
    rename v15 First_Name_B
    rename v16 Last_Name_B
    rename v17 Age_Dist
    rename v18 Dist_FN
    rename v19 Dist_lN
    export delimited "/Users/vardanyang/Dropbox/Irish migration - NSV/Ellis Island/Distances_1.csv"


    After this when I open the csv file in the computer, the changes are saved but when I import it in STATA, the changes are not saved.

    Can you please let me know how to proceed so that the changes are saved?

    Thanks,
    Ciara

  • #2
    You need to add the option - replace -, because this is a pre-existent dataset.

    Hopefully that helped
    Best regards,

    Marcos

    Comment


    • #3
      Hi Marcos,

      I actually get the same thing: the names do not change when I import the csv file into STATA, even after using the replace option.
      Ciara

      Comment


      • #4
        Are you sure Stata isn't refusing to import because data is already in memory? Showing exact commands and output might help.

        Also, I would give the new csv file a different name. I don't like destroying an earlier version this way. You might decide you want to do something differently and re-use the file you have overwritten.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 19.5 MP (2 processor)

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

        Comment


        • #5
          You might also issue a clear all command before trying to read in the new csv file. Maybe Stata keeps the old data in memory.
          -------------------------------------------
          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
            Also, make sure the ‘new’ file is in the wished directory.
            Best regards,

            Marcos

            Comment

            Working...
            X