Announcement

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

  • Strings going on the next line when importing a .csv

    Hi all,

    I have a .csv file that I have to import in stata. Specifically, what happens when I import it is that the string variable called city_agg is too long to be imported in a single line from time to time. Hence, it goes to the next line creating a new unwanted observation like this (see picture below).

    Is there a way to either prevent this behavior or tell stata that the observation where this happens (i.e. where the first variable is different from a number) must go on the last variable of the previous row?

    Thank you
    Click image for larger version

Name:	Screenshot 2022-10-03 at 10.01.57 AM.png
Views:	1
Size:	120.0 KB
ID:	1684071

  • #2
    Perhaps you could copy one of the troublesome lines from the CSV file and paste it - using CODE delimiters - into a reply on this topic so that we can better understand what Stata is seeing.

    Comment


    • #3
      cleaning up the csv might be an easy approach. replace spaces with underscore or shorten up the text.

      Comment


      • #4
        Hi all, and thanks for the kind replies. Actually, I found it easier to clean the .csv and import it to stata after this operation. Thank you for the replies-

        Comment

        Working...
        X