-1

I am currently trying to run some Stata code related to the WRDS database for my Ph.D. It is a postgres database requiring some configuration via ODBC. While isql connection via Terminal works, the command odbc list in Stata returns the following error:

The ODBC file libodbc.dylib could not be found on this system. Setting the unix LD_LIBRARY_PATH environment variable may correct this error.

I mainly followed the tutorial on https://gist.github.com/JonathanWillitts/7b5a519bd40dd730b98ce1ad75e859e8, trying to adapt it to the Postgres requirements for the Database via homebrew and psqlodbc. I assume the error comes from the variable export via Terminal that I use:

export LD_LIBRARY_PATH=/opt/homebrew/lib/ && /Applications/Stata/StataSE.app/Contents/MacOS/StataSE &

Nick Cox
  • 35,529
  • 6
  • 31
  • 47
  • 1
    Have you tried the remedies from https://stackoverflow.com/questions/66233373/stata-is-not-seeing-environment-variables-needed-for-odbc-connection ? – dimitriy Jan 20 '23 at 12:45
  • As it seems not recommended to disable SIP, I tried to follow the comments on setting the right path for LD_LIBRARY_PATH. However, the example refers to maridb and not postgres/psqlodbc. As I am not very familiar with the path exports on Mac, does anybody has an idea on how to adapt the path export to match for Homebrew/psqlodbc? – Christopher Jan 21 '23 at 10:51
  • Can you find where homebrew put the psqlodbc library? – dimitriy Jan 21 '23 at 18:22
  • I have located two files regarding psqlodbc, the .so file in /opt/homebrew/Cellar/psqlodbc/13.02.0000_1/lib/psqlodbca.so, as well as the .dylib file in /opt/homebrew/lib/. However, the latter is an Alias file that refers to a .dylib file in /opt/homebrew/Cellar/unixodbc/2.3.11/lib, which I do not understand why this is the case. But with in the psqlodbc-folder in "Cellar", there is no file with the ending .dylib – Christopher Jan 23 '23 at 17:53

1 Answers1

0

I have had success downloading WRDS data into R using the RPostgres package.

If you do not figure out how to download WRDS data directly into Stata, a possible workaround is to:

https://datascienceplus.com/exporting-data-from-r/

I am happy to share R code for obtaining WRDS data. Let me know if this interest you and I can share my R code here.

TC1
  • 21
  • 4
  • FYI, information from Stata: - Stata 17, https://blog.stata.com/2022/01/27/wharton-research-data-services-stata-17-and-jdbc/ Also see what this search finds, https://www.google.com/search?q=wrds+stata&rlz=1C1CHBF_enUS731US731&sxsrf=AJOqlzUywzUiWVPIXO4Imkm03ffMwEToVA:1674747646889&source=lnt&tbs=qdr:y&sa=X&ved=2ahUKEwjNz9KUyeX8AhVfEFkFHSeeCZMQpwV6BAgBEBk&biw=1536&bih=775&dpr=1.25 – TC1 Jan 26 '23 at 15:43
  • Configuring ODBC is a real drag even when you are comfortable with the command line. Setting up access through RPostgres is a breeze and the data wrangling capability of R is going to be much greater. Simply use haven::write_dta() at the end if you want to read the data in Stata. Many code examples here: https://iangow.github.io/far_book/fin-state.html – Ian Gow Apr 23 '23 at 02:06