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

A CLOSER LOOK: STATA DATA FILES ACROSS VERSIONS

Оглавление

As was noted in the Preface, the vast majority of Stata features and commands are similar across versions (e.g., Stata 15, 14, 13, etc.). This is true of Stata data files by and large. All Stata data files that are created and/or saved in an older version can be read by a newer version (i.e., they are forward compatible). This means that if you are using Stata 15 but are working with colleagues who are using Stata 14, any files they send to you will open without a problem.

During certain upgrades, however, Stata data files cease to be “backward” compatible, meaning files saved in a newer version cannot be opened by older versions. Stata 13 happened to be one of those upgrades. If you are using Stata 15 and send a data set that you saved in Stata 15 to your colleagues who are using Stata 13 (or earlier), they will not be able to open it. (Note: This is not a problem if you are moving files between Stata 15 and Stata 14, as these two versions are completely compatible with each other.)

Do not despair. Stata has built in a very simple feature to overcome this problem. If you know that you want the data you are using in Stata 15 to be opened by older versions, you need to take one extra step (from the process just explained).

First, click on the File menu and then click on Save As. Now, use the drop-down menu in the Save as Type box and select the Stata 13 Data (*.dta) option or the Stata 12/11 Data (*.dta) (if your colleague happens to be using a version prior to Stata 13). Note that you do not need to change the file extension; it is still .dta. Once you have named your file, click Save. You will know that you have saved the data correctly when the output in the Results window starts with .saveold, which is telling you that the file has been saved in a way that makes it readable by the previous versions. Again, note that when you save a file in this way, it can still be used in Stata 15.

This new window, as is denoted in its upper left-hand corner, is the Data Editor (Browse) window. The “(Browse)” aspect indicates that you are only looking at the data, not actually changing them.

In this window, you see all five of the variables that were listed in the Variables window. As was mentioned earlier, each row is a different case (i.e., a National Study of Youth and Religion [NSYR] respondent), and each column is a different variable. Each cell then contains information on the given variable for that case. For example, the case in the first row is a “Male” respondent who mentioned that “Mormon” was his other religion. To close this window, click on the red “X” in the upper right-hand corner.

There may be times when you would want to change the value of a particular case on an individual variable. One way to do so is by using the Data Editor window. (A more efficient way to change the values of multiple cases is covered in The 5 Essential Commands: replace (if) section of Chapter 2.) To begin, click on the Data Editor icon, , which is next to the Data Browser icon. You may notice that the Data Editor and Data Browser windows look very similar. The main difference is that in the upper left-hand corner of the window, after “Data Editor,” the window now reads “(Edit).” It is important to know which window you have opened because you can change the values of the data when the Editor is open. To prevent any accidental alterations, it is generally advised only to use the Data Browser window, unless you are certain you want to change a particular value.

After you have opened the Data Editor window, use the direction keys (or mouse) to highlight the cell you would like to change. For example, you may have realized that the first case’s age was incorrectly entered in the data file. Instead of being 23 years old, this case should only be 22 years old. To make this change, once you have the cell in the first row listed under agecats highlighted, type 22 and press Enter. This case’s value for the variable agecats has now changed. When you close the Data Editor window, this operation has been recorded and displayed in both the Review and Results windows.

Using Stata for Quantitative Analysis

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