Home  /  Resources & support  /  FAQs  /  Configuring ODBC for Windows

How do I set up an ODBC data source name in Windows?

Title   Setting up an ODBC data source name in Windows
Authors Rebecca Pope and Kerry Kammire, StataCorp

Stata's odbc command allows you to load, write, and view data from Open DataBase Connectivity (ODBC) sources. Before you start using the odbc command in Stata, you must first set up a data source name (DSN) in the ODBC Data Source Administrator. Setting up a DSN differs slightly depending on your version of Windows.

Windows 10

  1. On the Start page, type ODBC Data Sources. The ODBC Data Sources Desktop App should appear as a choice.
  2. In the ODBC Data Source Administrator, click on the Add button.

    ODBC Data Source Administrator

  3. Select the appropriate driver from the list. The driver that you need is determined by the data source you are trying to connect to. For example, choose Microsoft Access Driver (*.mdb) to read from a MS Access database.

    ODBC Data Source Administrator - Add

    Click on Finish.

  4. Assign a name and select the appropriate source. The DSN is completely up to you. You will see a list of available databases or, if you are using Excel, available files. Select the ones you want to associate with the DSN you just created.

    The appearance of this dialog box and the number of prompts required to complete this step will vary depending on the ODBC driver you are using.

  5. Once you have finished configuring your data source, you should see your new DSN in the list shown in the ODBC Data Source Administrator User DSN tab.

    ODBC Data Source Administrator - Add

You are now ready to begin using the odbc command. If you encountered any problems during the setup process, there are some troubleshooting tips below.

Using the odbc command

Now that you have set up your DSN, open Stata, and type odbc list in the Stata Command window. You should see your new data source displayed in the Results window.

. odbc list

Data Source Name                   Driver
-------------------------------------------------------------------------------
test                               Microsoft Access Driver (*.mdb)
-------------------------------------------------------------------------------
To find out how to do useful things with your data source, such as read from it and write to it, see [D] odbc.

Troubleshooting

If you encounter the error r(682) "Data source name not found and no default driver specified", follow these steps.

  1. Make sure you have your DSN configured correctly. Go back into the ODBC Data Source Administrator, and double check your data source settings.

  2. Make sure you are using the correct version of the ODBC Data Source Administrator. 64-bit Windows ships with two different ODBC Data Source Administrators, 64-bit and 32-bit. Stata 16 and later are 64-bit, so you need to use the 64-bit ODBC Data Source Administrator.

    Microsoft provides additional information and support for the Windows ODBC Data Source Administrator:

    http://support.microsoft.com/kb/942976
  3. Make sure you are using the correct driver for the DSN. If you are using Stata 16 or later, you need a 64-bit driver. You should be able to download the appropriate 64-bit database driver from your data source's database vendor. You will have to follow the driver installation instructions for it to show up in the ODBC Data Source Administrator.