Announcement

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

  • Install Previous Version of Stata?

    Hi everyone,
    we are using google translate to translate variable values in string txt format and add them to our dataset

    we did this with no problem from the GUI using either excel or google sheets to prepare the data as a large column then copy paste in the stata browser editor window.

    now for some reason this operation has become not working bc something with format of cell style in stata breaks up the values into more than one value bc of linebreaks etc

    our workflow would make it a lot easier if we can continue to use the copy paste we did before. The only thing we can figure is that a previous version of stata allowed this and the latest does not.

    SO

    How can I install an older, previous version of stata to see if we can get it to work?

    Thanks!

    - Will

  • #2
    Much easier than installing a previous Stata version would be to save your one column Excel file and use -import excel- on it to make it a Stata file before merging it. If this is indeed a "large column," as you say, the time to do this rather than cut and paste would be trivial relative to the total prep time, and could be more or less routinized into a short special purpose program. Further, it would give you the advantage of a safe or dependable work process for serious data analysis, the lack thereof beings generally regarded as an unsavory feature of cut and paste practices being used for data preparation. If this work process seems onerous or difficult or unworkable, I'd encourage you to seek help here on that problem, as it should not be so.

    That being said, if you can show us a simple reproducible example of the problem, that would be helpful in help us figuring out what is going on. I would guess that the problem derives from something within the cells you are trying to cut and paste, such as a tab character. I can understand that it might be hard to give an example without attaching a binary file (deprecated on StataList), so you might have to resort to giving a description such as "If you translate "whatever" into French with Google Translate, paste it into Excel, and then try to paste it into Stata ... ."

    Comment


    • #3
      Thank you so much for this detailed reply Mike.
      I am going to hand this over to my colleague Rachel and get back to you --

      Comment


      • #4
        Here is the .do file that my colleague generated as a double workaround on this -
        export to sheets
        translate
        reimport using merge

        what the problem is that Stata is not allowing copy paste in the more recent version bc there are line feed carriage return characters.
        This wasn't a problem in previous versions of stata where this exact same translation copy paste deal worked fine
        that is just a guess tho - period - space - new sentence created a new row when we exported.

        ***Translation Template

        *Part 1:
        use "\\files\users\rflanigan\Documents\ATP\8_13ImportT oSTATA_V3.dta"
        gsort -whywithd_txt
        save "\\files\users\rflanigan\Documents\ATP\8_13ImportT oSTATA_V3.dta", replace
        export excel id whywithd_txt using "\\files\users\rflanigan\Documents\ATP\text test12.xlsx", keepcellfmt

        * for will: export excel id whywithd_txt using "/Users/willhall/Downloads/ExcelTransport.xlsx", keepcellfmt replace

        *In the above section "\\files\users\rflanigan\Documents\ATP\8_13ImportT oSTATA_V3" is the path and filename to the
        * file to be translate to prepare for import of new respondents.

        "text test12" is the name of the working scratch file to make the translation import possible\\

        * "export excel id whywithd_text specifies to export only the variables: id & whywithd_txt

        **Part 2:
        *In Sheets:
        *(1) File - Import - Upload - Replace existing sheet
        *(2) Name sheet
        *(3) Translate
        *(4) File - Download - Microsoft Excel .xlsx
        **(I tried this with csv & tsv but got formatting problems)

        ***Part 3:
        *In STATA
        import excel "\\files\users\rflanigan\Downloads\text test sheet.xlsx", sheet("Sheet1") clear
        drop B
        rename A id
        rename C translate
        drop if id==.
        replace translate=strtrim(translate)
        replace translate=stritrim(translate)
        save "\\files\users\rflanigan\Documents\ATP\whywithtran slate.dta", replace

        *In the above section strtrim removes blank spaces before & after the response
        **stritrim removes blank spaces greater than 1 character from the response
        *** Still won't work using copy paste method to sheets again, bc it still had the row breaks

        ****Part 4:
        * go back to the original translate file you started with and merge what we just did into it
        use "\\files\users\rflanigan\Documents\ATP\8_13ImportT oSTATA_V3.dta"
        gsort -whywithd_txt
        merge 1:1 id using "\\files\users\rflanigan\Documents\ATP\whywithtran slate.dta"
        drop _merge
        order translate, after(whywithd_txt)
        drop whywithd_txt_trs
        rename translate whywithd_txt_trs
        save "\\files\users\rflanigan\Documents\ATP\8_13ImportT oSTATA_V3.dta", replace

        *In the above section you open the respondent import file, then merge the translations into it by matching responses by respondent id number. Then you order the variable in the data set and make it the whywithd_txt_trs variable.






        Comment


        • #5
          Providing an example file where Stata 'breaks' would only be too easy.
          As Mike Lacy requested above.
          If you are copying and pasting data from Excel, the example of DATA, not CODE is necessary. Any subsequent merges or sorts are irrelevant if your data is input incorrectly.

          That said, your assumption that
          what the problem is that Stata is not allowing copy paste in the more recent version bc there are line feed carriage return characters.
          Is unlikely. At least when the data is transferred via code:
          Click image for larger version

Name:	line-breaks.png
Views:	1
Size:	17.9 KB
ID:	1568914



          As can be seen from the above snapshot, Stata read the data file correctly maintaining a single value in A1 with line break characters inside.

          What you need to realize is that you will have the same problem pasting into any other software, take notepad for example. The software needs to know, what to do with the incoming line breaks and since different people have different needs, there may not be one solution that fits all.

          Click image for larger version

Name:	special.png
Views:	1
Size:	23.8 KB
ID:	1568915


          Now, next time you try to paste content from Excel to Stata with embedded line breaks, don't rush and reach for the 'Paste special' rather than 'Paste'. There pick that your delimiter is a tab and that double quotes bind tokens. Here the double quotes are left for illustrative purposes, but there is an option there to strip the double quotes as well.

          Hope this helps.

          PS: In the Stata world "this version" and "earlier version" are meaningless. Use "version 13" or "version 15.1 build 681" better yet with platform, bit-width, flavor and any other descriptors, especially in the cases where you imply that version matters. Like here.

          Best,
          Sergiy

          Comment

          Working...
          X