Announcement

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

  • Importing a .csv file with standard stata encoding

    Hi all,

    I am trying to import a.csv dataframe looking like this (please notice columns new_a1 and new_a2):
    Click image for larger version

Name:	Screenshot 2022-09-28 at 7.11.18 PM.png
Views:	1
Size:	150.6 KB
ID:	1683655


    Unfortunately, I was not able to attach a datex since I could not import the data properly yet. However, I have attached a sample of the data in .csv format.
    When I import the data with import delimited the message appearing (several times acutally) is:

    Code:
    Note: Unmatched quote while processing row 2764799; this can be due to a formatting problem in the file or because a quoted data
        element spans multiple lines. You should carefully inspect your data after importing. Consider using option bindquote(strict) if
        quoted data spans multiple lines or option bindquote(nobind) if quotes are not used for binding data.
    (
    Since I have ecer adopted the option bindquote and am not sure whether this might solve my problem I would like to as you how you would proceed to import the data.

    Thank you
    Attached Files

  • #2
    Code:
    import delimited ../sampledata.csv, delimiter(comma) bindquote(nobind) varnames(1) stripquote(no) encoding(utf8)
    try this, of course you have to specify the correct path.

    Comment


    • #3
      Thank you for the reply. It worked. The only thing is that, in some cases (not included in the sample), some rows were so long that went on the next line in the .csv. This results in the following
      Click image for larger version

Name:	Screenshot 2022-09-29 at 10.02.29 AM.png
Views:	1
Size:	40.2 KB
ID:	1683716


      that is it goes on the next line also on the stata file. Is there a way to get around this?

      Thank you again

      Comment

      Working...
      X