2.0 Demonstration and explanation

We will start with inputting a spreadsheet type of data file into Stata. A
spreadsheet type of file is created by programs such as Excel. For example, in
Excel, we can save a file into a comma-separated-values format (.csv) file. Stata
reads in this type of data using the insheet command. Let's first get to the
directory where the file hs0.csv is. This data file has variable names
on the first line.

Notice how we specify a character variable below. The variable
prgtype is a character variable. We tell Stata this and that we want it to
have a length of 10 by typing str10 before the variable name. We will use
the hs0.raw data file.

The other type of commonly used ASCII data format is fixed format. It always
requires a codebook to specify which column(s) corresponds to which variable. Here is small
example of this type of data with a codebook. Notice how we make use of the
codebook in the infix command below. We will use the
schdat.fix data file.

We can also use the Do-file editor to input data. The Do-file editor is used for
writing a sequence of commands and running them all at once. You can copy and paste
the following Stata syntax to the Do-file editor and run it.

After running the above program, we can issue the describe command to get a
general idea about the data set. The compress command reduces the size of
the data set. We can save the data set to disk by issuing the save command.

describe
compress
save hsb10

To read in a Stata data file, we use the use command.

clear
use hsb10

The use command can also be used to read a data file over the
internet.

use http://www.ats.ucla.edu/stat/data/hs0, clear

Sometimes, the data file may be too big to be read in. We will have to reset
the amount of memory allocated to Stata.

clear
use http://www.ats.ucla.edu/stat/data/large
memory
set memory 5m
use http://www.ats.ucla.edu/stat/data/large, clear