Announcement

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

  • Rui Tiago
    started a topic Import text data not delimited

    Import text data not delimited

    Dear Stata users,
    I am trying to import .txt data into Stata. The main problem is that my data is not delimited. Using space as a delimiter also does not work because in some variables there are two words or more (ex.: line 6 of my data example). Here is an example of my data:

    Code_du_département Libellé_de_département Code_Insee_de_la_commune Libellé_de_la_commune Population_de_la_commune Nom_de_lélu Prénom_de_lélu Code_sexe Date_de_naissance
    01 AIN 001 L'Abergement-Clémenciat 780 BOULON Daniel M 4/3/1951
    01 AIN 002 L'Abergement-de-Varey 234 GONNAND Robert M 28/2/1929
    01 AIN 004 Ambérieu-en-Bugey 13839 EXPOSITO Josiane F 3/3/1943
    01 AIN 005 Ambérieux-en-Dombes 1600 PERNET Pierre M 29/7/1961
    02 AISNE 774 Vendelles 109 PRUVOST Stéphane M 28/6/1976
    05 HAUTES ALPES 071 Lardier-et-Valença 304 COSTORIER Rémi M 11/10/1959

    Could anyone advice me how should I code, to be able to import my data? I am using Stata 16.

  • Rui Tiago
    replied
    It solved the problem, and so simple. Thank you so much!

    Leave a comment:


  • William Lisowski
    replied
    It is extremely unusual for data to be presented with no delimiter.

    It is common for data to be presented with a "tab" character as the delimiter, and that tab character may not be visible when you view the file in a text editor.

    If you are using the import delimited command, try adding the option
    Code:
    delimiters("\t")
    and see if that solves the problem. If you are using Stata's menus and dialog boxes, you should choose "Tab" from the "Delimiters" drop-down in the "Import delimited text data" dialog box. If you have yet to try either, I'd suggest starting with the menu and dialog box because it makes experimentation easier.

    Leave a comment:

Working...
X