Agriculture Reference
In-Depth Information
dictionary {
_firstlineoffile(22)
_lines(1)
int rep
int var
str8 date
float yield
}
Figure 2.6
Example of a data dictionary used to import data.
This is where a data dictionary can be helpful in inputting such
data. Only the data with the column labels should become part of the
data file. To do this, you must create a data dictionary file, which is
just a plain text file set up in such a way that Stata can use this diction-
ary to determine how the data should be input. The Do-File Editor
is a good place to create this file, although any text editor or word
processor can be used.
Figure 2.6 has the data dictionary created to import the data from
the file shown in Figure 2.5.
The data dictionary must have the word dictionary in the first line
with an open brace ({). The first line after that tells Stata that data should
be imported starting at line 22. The next line indicates that each observa-
tion is on one line. This is really not necessary in this case because Stata
can figure this out. It does imply, however, that data can be imported
with a single observation that is contained on more than one line. The
next four lines indicate the data type and variable name for each vari-
able. int is for an integer type, which is a number without any deci-
mals; str8 is for a string or text type that is eight characters or less in
length. float indicates that data type is a floating number, i.e., it has
a decimal value. These explanations are somewhat simplistic and Stata's
Help files and manuals have more detailed information about data types.
Dictionaries should be saved with a .dct extension so Stata will recog-
nize them.
Figure 2.7 shows the input dialog window. This window is selected
under the File menu, under the Import submenu. Select the sub-
menu item: Text data in a fixed format with a dictionary. Select the
Browse… button for the dictionary filename and load the Infiledict
.dct file from the Data Files folder. Then do the same to load the text
Search WWH ::




Custom Search