Announcement

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

  • Importing text file data

    Dear Statlist,

    I am trying to import this text file to stata , however every time I try to import it the variables shift from one column to another

    My data look like this,



    1,|Q406|,|9569471|,|1392702|,||,|Ursula Kuster-Wagstaff|,10,07/11/2006,|Ursula Wagstaff-Kuster|,||,|Y4000|,|912166949|,|PI|,,|Fairbanks Republican Women Federated|,|Rancho Santa Fe|,|CA|,|92067|,||,|7320|,|Unknown|,|Unknown|,139 80,|F|,||
    2,|Q406|,|9569471|,|1392232|,||,|Pendrey Boteler|,65,12/28/2006,||,||,|Y2000|,|912166949|,|PI|,,|Fairbanks Republican Women Federated|,|Rancho Santa Fe|,|CA|,|92067|,|8674|,|7320|,|Unknown|,|Unknown| ,305,|U|,||
    5,|Q406|,|9569471|,|1392234|,||,|Elizabeth Brayshay|,75,02/16/2006,||,||,|Y2000|,|912166949|,|PI|,,|Fairbanks Republican Women Federated|,|El Cajon|,|CA|,|92020|,||,|7320|,|Unknown|,|Unknown|, 350,|F|,||
    1451228,|Q317|,|9656942|,|7539972|,||,|CARVER, MICHAEL|,3,07/05/2017,|Unemployed |,||,|Y1000|,|202517748|,|PI|,,|ActBlue Non-Federal|,|RIDGEFIELD|,|WA|,|98642|,||,|6440|,|NOT EMPLOYED|,|NOT EMPLOYED|,250,|M|,|Gen|
    1451229,|Q217|,|9656643|,|7512623|,||,|William Clark|,5,05/29/2017,||,||,|Y2000|,|521870839|,|DP|,|D|,|Democrati c Legislative Campaign Cmte|,|Reading|,|PA|,|19606|,|9048|,|6680|,|Inform ation Requested|,|Information Requested|,360,|M|,||

    Any suggestions ?
    Last edited by Mohamed Mahmoud; 23 Feb 2023, 15:11.

  • #2
    If you showed us the exact Stata command(s) you used to import the data, and showed an example of what you mean by "variables shift from one column to another," there's a good chance someone could help you. Without that, responding effectively to your problem is hard.

    Comment


    • #3
      Thanks for your advice,

      Firstly , I attached the text file here , so you can have an idea about the text file itself

      Secondly, I used this command

      Code:
       import delimited "test.txt", delimiter("|,|") parselocale(en_US)

      if you download the text file and try to import the data , you will find "V15" shift to the next variable , which makes a problem in the next variables .


      Many thanks

      Attached Files

      Comment


      • #4
        Your 3 character argument to the -delimiter- option specifies 2 one character delimiters, "|" and ",". See https://www.stata.com/manuals/dimportdelimited.pdf.

        Just looking at the sample, it may be that if you do a global replace of vertical bar with a quote mark, and use comma as the delimiter, the import might work, assuming there were no quote marks in the data. You could use your favorite text editor or Stata's -filefilter- described at https://journals.sagepub.com/doi/pdf...867X0800800209

        Comment


        • #5
          Many thanks Daniel , your suggestions worked perfectly


          Comment

          Working...
          X