Читать книгу Using Stata for Quantitative Analysis - Kyle C. Longest - Страница 23

A CLOSER LOOK: VARIABLE TYPES

Оглавление

You may have noticed that more information about the variable type is listed in the Properties window. For example, gender is shown to be a byte variable, ids is a long variable, and religoth is a str31 variable.

These distinctions further demarcate variables within the general categories of numeric and string. They are also related to how much file space is allotted to store the variable.

All string variables have the “str” prefix, and the number indicates the maximum characters that can be used for that string variable. So the maximum length a denomination could be in the variable religoth is 31 characters. As you will see, this constraint can be altered, but it is advisable to use only the minimum number of characters that are needed. Otherwise you are using memory to store empty spaces.

Similarly, the various subtypes of numeric variables indicate the number of digits that each variable can hold. In order from the smallest to the largest, the numeric variable types are byte, int, long, float, and double.

Generally, Stata will store variables in the most efficient and effective way when you create them. Moreover, most Stata users will conduct countless analyses without ever having to worry about or manipulate these specific distinctions.

When you have the Data Browser open, you will probably notice, however, that the variables gender and employst look different from the variables ids and agecats. This difference is due to the fact that gender and employst have what are called value labels attached to them. Value labels will be covered in much more detail later, but they are labels that can be applied to the numeric codes used to represent responses. Remember that you could decide to use the number 1 to represent the answer “Female.” This choice may be difficult to remember (i.e., whether 1 was Male or whether 1 was Female); therefore, you can use value labels as a way to help remember this coding strategy. The variables ids and agecats were numerical responses, so they do not have any value labels that could be attached to them. You can see the actual numerical codes for each variable using the Data Browser window by clicking on the Tools menu, selecting Value Labels, and clicking Hide All Value Labels. When you do so, you will see the cases that were “Male” now display “0,” and the cases that were “Female” now display “1.” Or you can highlight (using either the direction keys or the mouse) a particular cell (e.g., “Male”). When you do so, the actual value is listed in a pane just underneath the icons.

Using Stata for Quantitative Analysis

Подняться наверх