Stata Study Notes (ii): fixed-width data import

Source: Internet
Author: User

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

    1. According to the characteristics of the data to write a . DCT file, the file must indicate the path and name of the read data.
    2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.