Announcement

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

  • Convert/Save labeled .dta file to .txt file

    Hi Statalist,

    I am struggling with a seemly very simple question in Stata, but really cannot figure it out...

    Basically, I have a dataset with labeled numeric variables (.dta), and after the data management and cleaning in Stata, I want to output and save it as .txt file (without label). Here is the code I used, the .txt file could be saved, but it contains a lot of weird strings, instead of the all the numeric values I wanted. I wonder what is going wrong with my codes.

    Thanks in advance!
    Yingyi

    Code:
    use old_data.dta, nolabel
    save new_data.txt, replace

  • #2
    see
    Code:
    help outfile

    Comment


    • #3
      Also see -help export delimited-.

      Comment


      • #4
        Originally posted by Rich Goldstein View Post
        see
        Code:
        help outfile
        Hi Rich, I tried the outfile commands as well, but still it did not work.

        Code:
        outfile old_data.dta, comma replace
        when I was running this line of code (no matter with old_/new_data), error saying that "file XXX could not be opened"

        Comment


        • #5
          Originally posted by Clyde Schechter View Post
          Also see -help export delimited-.
          Hi Clyde, this helps! Thanks a lot!

          I ended up using the code:

          Code:
          export delimited new_data.txt, delimiter(tab) replace

          Comment


          • #6
            re: #4, the command you used does NOT match what the help file says to do

            Comment


            • #7
              Originally posted by Rich Goldstein View Post
              re: #4, the command you used does NOT match what the help file says to do
              Thanks Rich, your notice made me re-read the document and now I got it. Here is the code I ending up using:

              Code:
              outfile using old_data.txt, wide replace
              Works perfectly

              Comment

              Working...
              X