First, what is fixed-width data
A fixed-width number on a certain or some number of digits represents the data of a certain class of information. The simplest and most straightforward example of your identification number.
There are two types of data file formats for raw and txt .
Second, the import procedure
- According to the characteristics of the data to write a . DCT file, the file must indicate the path and name of the read data.
- Use the infile command to read in. dct files, typically:
using dfilename[if[in] [, Options] //Dfilename is a. dct file that requires a path;
Examples (DCT files and do-file files):
1DictionaryusingD:\Stata12.0\data.txt {//indicates that this is a. dct file, and the using is followed by the data that corresponds to the read-in is the Data.txt file in the D-Disk Stata12.0 directory2_lines (2)//every two lines are read in as a record3_line (1)//indicates first reading from line 1th4_column (1)//indicates that the first reading starts from column 1th5 LongIdnumb%9f"Identification Number" //Read 9-width long integer6STR6 Sex%6s"Sex" //6-width character type7 intAge%2f" Age" //2-width integer data8_column ( -)//indicates that the cursor jumps directly to the 24th column, usually because there are spaces in the middle to take the practice9 floatIncome%6f"Income" //: The double quotes section is a supplementary description of the variable, which we call "tagging"Ten_line (2)//jump to the 2nd line of data file to start reading OneSTR9 Eval%9s"Evaluation" A } - //: The last line of the. dct file needs to be empty, otherwise it will error. The last line of the data file will also be empty.
1 using SCORE.DCT, Clear 2 List
Stata Study Notes (ii): fixed-width data import