Announcement

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

  • Importing Text Data

    Hello ,
    I want to learn how the following attached sample TEXT data can be imported in Stata( 12 version) without using Stat/Transfer . Note this dataset loses its dictionary file.
    Thanks in early advance for your support.


    Attached Files

  • #2
    Welcome to Statalist!

    Your data is like a CSV file, but instead of commas, it uses the "pipe" character | as the delmiter. (On my Mac, that's on the same key as the \ character.) Reading delimited data is described in help import delimited and in more detail in the Stata Data-Management Reference Manual PDF.

    You can most easily import the data interactively. Starting on Stata's File menu, choosing Import > Text data (delimited, *.csv, ...), and in the dialog box that opens, first browse for and select your data file, and then set the Delimiter to Custom and then type the pipe charcacter in the box that appears to the right. Once you've done that, the preview at the bottom will show your data as it will be imported. You can then adjust the other options as needed.

    Comment


    • #3
      Dear Lisowski,
      As per your suggestion, I tried the interactive way of import window which turns out to be the actual command as : insheet using "filename", delimiter("|")
      It imported my data partially only. I cannot understand what went wrong in this technique!

      Comment


      • #4
        Without reviewing the results line-by-line, I appear to have successfully imported your sample data, as below. Your sample data had 37 lines, the first being the names of 43 variables, and Stata created the 44th variable (as always missing) because each line ends with a pipe character before the end-of-line character.
        Code:
        . import delimited "/Users/lisowskiw/Downloads/sample_data.txt", delimiter("|") 
        (44 vars, 36 obs)
        You should review the Statalist FAQ linked to from the top of every page, especially sections 9 though 12 on presenting problems in a way that the reader can understand what the problem is. You ran the import command, saw the results, saw how they differed from what you expected, and write that you cannot understand what went wrong. How are your readers to understand what went wrong when they haven't seen the results and haven't been told how they differed from what you expected? "Partial data" might mean
        • too few variables were created
        • too few observations were read
        • some variables were only partially read and truncated

        Comment


        • #5
          Dear Lisowski,
          I successfully imported my data applying your suggestions now in Stata 13. Thank you very much!!!
          Last edited by Ram Regmi; 02 Aug 2015, 00:17.

          Comment

          Working...
          X