Announcement

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

  • Reading a .DAT file from a .txt dictionary

    Dear statalist,
    I am working with a survey in which data comes in ASCII format (.DAT) and the dictionary (gives the position of the variables) of the file is in (.txt). What I am doing is creating a do.file that read this .DAT file using the command infix (see below and example)
    Code:
    infix ORDINAL 1-10 AA_1993 12-23 AA_1994 25-36 AA_1995 38-49 AA_1996 51-62 AA_1997 64-75 AA_1998 77-88 AA_1999 90-101 AA_2000 103-114 AA_2001 116-127 AA_2002 129-140 AA_2003 142-153 AA_2004 155-166 AA_2005 168-179 AA_2006 181-192 AA_2007 194-205 AA_2008 207-218 AA_2009 220-231 AA_2010 233-244 AA_2011 246-257 AA_2012 259-270 AA_2013 272-283 AA_2014 285-296 AA_2015 298-309
    I am wondering if there exist an easy way of doing this automatically, since the dataset is long, this can induce me to make a mistake when typing. I have see that the import option allow to do something like that, I mean, to read the file using the dictionary automatically. However, I tried but it seems that the file should be .raw and the dictionary should be .dct
    Code:
     infix using "C:\Users\dtojeiro\Dropbox\PhD\Second Paper ESEE_DATA\ESEE_2015\Datos actualizados\ESEE_Jul2017.txt", using("C
    > :\Users\dtojeiro\Dropbox\PhD\Second Paper ESEE_DATA\ESEE_2015\Datos actualizados\ESEE_Jul2017.DAT")
    Relaci�n de variables del fichero : ESEE_Jul2017
    file does not contain dictionary
    r(613);
    This is the error I get if I try using the files I have .DAT for data and .txt for the dictionary.
    Can anybody tell me if it is possible what I want to do, and then, how specifically tell Stata to read .DAT using the dictionary in .txt?

    Many thanks in advanced for your help and time.

  • #2
    This is how the dictionary looks like:

    Code:
    Relación de variables del fichero : ESEE_Jul2017
    
       Nº de Registros =  5566
    
       1  ORDINAL                          1 -    10
       2  AA      
           Ejercicio ....... 1993         12 -    23
           Ejercicio ....... 1994         25 -    36
           Ejercicio ....... 1995         38 -    49
           Ejercicio ....... 1996         51 -    62
           Ejercicio ....... 1997         64 -    75
           Ejercicio ....... 1998         77 -    88
           Ejercicio ....... 1999         90 -   101
           Ejercicio ....... 2000        103 -   114
           Ejercicio ....... 2001        116 -   127
           Ejercicio ....... 2002        129 -   140
           Ejercicio ....... 2003        142 -   153
           Ejercicio ....... 2004        155 -   166
           Ejercicio ....... 2005        168 -   179
           Ejercicio ....... 2006        181 -   192
           Ejercicio ....... 2007        194 -   205
           Ejercicio ....... 2008        207 -   218
           Ejercicio ....... 2009        220 -   231
           Ejercicio ....... 2010        233 -   244
           Ejercicio ....... 2011        246 -   257
           Ejercicio ....... 2012        259 -   270
           Ejercicio ....... 2013        272 -   283
           Ejercicio ....... 2014        285 -   296
           Ejercicio ....... 2015        298 -   309
       3  ACCID   
           Cuatrienio ... 2014 / 2017    311 -   316

    Comment

    Working...
    X