Announcement

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

  • Data importing and merging

    Hello,

    I have an issue with importing additional data into my code.

    I import a dataset (.dta) that I change to .smcl in the beginning of my code and use it for my analysis. At some point I end up with a column variable of type string, which is a list of different phrases in various languages (about 27000 rows). I want to create another variable with the English translation of those phrases.

    I have created an Excel spreadsheet with 2 columns (left = native phrases, right = English translation) with the translations of the unique phrases (about 300 rows), that I attempted to import as a macro and use to translate my initial variable, . However I am experiencing some issues.

    1) I was wondering if this is even an efficient way, or if you could recommend an alternative. Is there a similar way to work as with vlookup in Excel?

    2) My attempt:
    When importing the excel file, I get the error "no; data in memory would be lost", which as I understand means I need to save the existing data before importing a new one. However I can't seem to be able to save it.
    my code is:
    save "Users/....../...1.smcl", replace
    And I get an error saying "log file already open"
    Any ideas what I might be doing wrong?
    Also, would this delete my existing data? (I don't want to delete it as I need it for further analysis afterwards)
    And assuming I manage to import the Excel spreadsheet successfully and keep both that and my initial dataset
    How do I achieve the translation.

    Thanks in advance

  • #2
    try importing the all the different data sets and saving them as a dta. do all your merging with dta files. smcl, which I don't use, appears to be some type of logging procedure.

    Comment


    • #3
      Amplifying the advice in #2, .smcl is the mark-up language that Stata uses, by default, for logging output. You should not try to -save- a dataset with a filename extension .smcl. The resulting file will still contain the data organized as a .dta. But with the filename ending in .smcl neither Stata proper nor the Viewer (which is the Stata sub-app that reads .smcl files) will be able to open it. I'm not sure what you are even hoping to accomplish with that command anyway. Perhaps you can explain more clearly what the goal is here.

      That said, the original problem of -import excel- refusing to read your file because you have unsaved data in memory can be resolved either by correctly saving that file as a .dta file, or, if you do not need to keep that data, just add the -clear- option to your -import excel- command and Stata will gladly dispose of the data in memory and read in your spreadsheet.

      Comment

      Working...
      X