When Stata programmers publish a package centred on programs and their help files, they often make test datasets available, but the best standard is to mark such files as ancillary and let users download them to a location of their own choice using net get. As said, this is a choice. Try to cd to a directory where you know you have write access before downloading any such files. Regards, Sergiy On 6/4/08, Viktor Slavtchev wrote: Hello. 1) The problem I have is that I am able to download and run user written stata commands (for example -tmap-) but I am not able to download the ANCILLARY FILES.
All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:boc:bocode:s336401. See general information about how to correct material in RePEc.
For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: (Christopher F Baum). General contact details of provider: http://edirc.repec.org/data/debocus.html .
If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.
If CitEc recognized a reference but did not link an item in RePEc to it, you can help with this form .
If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the 'citations' tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.
Please note that corrections may take a couple of weeks to filter through the various RePEc services.
This module will show how to input your data into Stata. This covers inputting data with comma delimited, tab delimited, space delimited, and fixed column data.
Note: all of the sample input files for this page were created by us and are not included with Stata. You can create them yourself to try out this code by copying and pasting the data into a text file.
1. Typing data into the Stata editor
One of the easiest methods for getting data into Stata is using the Stata data editor, which resembles an Excel spreadsheet. It is useful when your data is on paper and needs to be typed in, or if your data is already typed into an Excel spreadsheet. To learn more about the Stata data editor, see the edit module.
2. Comma/tab separated file with variable names on line 1
Two common file formats for raw data are comma separated files and tab separated files. Such files are commonly made from spreadsheet programs like Excel. Consider the comma delimited file shown below.
This file has two characteristics: – The first line has the names of the variables separated by commas, – The following lines have the values for the variables, also separated by commas.
This kind of file can be read using the insheet command, as shown below.
We can check to see if the data came in right using the list command.
Since you will likely have more observations, you can use in to list just a subset of observations. Below, we list observations 1 through 3.
Now that the file has been read into Stata, you can save it with the save command (we will skip doing that step).
The exact same insheet command could be used to read a tab delimited file. The insheet command is clever because it can figure out whether you have a comma delimited or tab delimited file, and then read it. (However, insheet could not handle a file that uses a mixture of commas and tabs as delimiters.)
Before starting the next section, let’s clear out the existing data in memory.
3. Comma/tab separated file (no variable names in file)
Consider a file that is identical to the one we examined in the previous section, but it does not have the variable names on line 1
This file can be read using the insheet command as shown below.
But where did Stata get the variable names? If Stata does not have names for the variables, it names them v1, v2, v3 etc., as you can see below.
Let’s clear out the data in memory, and then try reading the data again.
Now, let’s try reading the data and tell Stata the names of the variables on the insheet command.
As the list command shows, Stata used the variable names supplied on the insheet command.
The insheet command works equally well on files which use tabs as separators. Stata examines the file and determines whether commas or tabs are being used as separators and reads the file appropriately.
Now that the file has been read into Stata, you can save it with the save command (we will skip doing that step).
Let’s clear out the data in memory before going to the next section.
4. Space separated file
Consider a file where the variables are separated by spaces like the one shown below.
Note that the make of car is contained within quotation marks. This is necessary because the names contain spaces within them. Without the quotes, Stata would think AMC is the make and Concord is the mpg. If the make did not have spaces embedded within them, the quotation marks would not be needed.
This file can be read with the infile command as shown below.
You may be asking yourself, where did the str13 come from? Since make is a character variable, we need to tell Stata that it is a character variable, and how long it can be. The str13 tells Stata it is a string variable and that it could be up to 13 characters wide.
The list command confirms that the data was read correctly.
Now that the file has been read into Stata, you can save it with the save command (we will skip doing that step).
Let’s clear out the data in memory before moving on to the next section.
5. Fixed format file
Consider a file using fixed column data like the one shown below.
Note that the variables are clearly defined by which column(s) they are located. Also, note that the make of car is not contained within quotation marks. The quotations are not needed because the columns define where the make begins and ends, and the embedded spaces no longer create confusion.
This file can be read with the infix command as shown below.
Here again we need to tell Stata that make is a string variable by preceding make with str. We did not need to indicate the length since Stata can infer that make can be up to 13 characters wide based on the column locations.
The list command confirms that the data was read correctly.
Now that the file has been read into Stata, you can save it with the save command (we will skip doing that step).
Let’s clear out the data in memory before moving on to the next section.
6. Other methods of getting data into Stata
This does not cover all possible methods of getting raw data into Stata, but does cover many common situations. See the Stata Users Guide for more comprehensive information on reading raw data into Stata.
Another method that should be mentioned is the use of data conversion programs. These programs can convert data from one file format into another file format. For example, they could directly create a Stata file from an Excel Spreadsheet, a Lotus Spreadsheet, an Access database, a Dbase database, a SAS data file, an SPSS system file, etc. Two such examples are Stat Transfer and DBMS Copy. Both of these products are available on SSC PCs and DBMS Copy is available on Nicco and Aristotle.
Finally, if you are using Nicco, Aristotle or the RS/6000 Cluster, there is a command specifically for converting SAS data into Stata called sas2stata. If you have SAS data you want to convert to Stata, this may be a useful way to get your SAS data into Stata.
7. Summary
Bring up the Stata data editor for typing data in.
Read in the comma or tab delimited file called auto2.raw taking the variable names from the first line of data.
Read in the comma or tab delimited file called auto3.raw naming the variables mpg weight and price.
Read in the space separated file named auto4.raw. The variable make is surrounded by quotes because it has embedded blanks.
Read in the fixed format file named auto5.raw.
Other methods DBMS/Copy, Stat Transfer, sas2stata, and Stata Users Guide.