How to Connect to the First Databank Drug Database
Total Page:16
File Type:pdf, Size:1020Kb
How to Connect to the First Databank Drug Database The First Databank Drug Database (FDB) is stored in a Mysql database running on Sasser1. The easiest way to connect to the FDB database in SAS is to use the libname statement. Step 1. Update your .bashrc Before you connect to the Mysql server using SAS, you need to add the paths to the Mysql library and binaries. To do this you will need to edit your “.bashrc” file. 1. Go to your home directory. (Type cd or cd ~). 2. Open the .bashrc file (type gvim .bashrc or use your editor of choice). 3. Add the following lines: . /data_prep/FDB/scripts/sas_sql_path **Note, there is a space between the “.” and the file path** 4. Save and close the .bashrc. 5. From your home directory type “source .bashrc” SAS Code: libname <name> mysql user=shouston password=houstonwehaveaproblem database=FDB server=sasser1; How to load a specific table: Now that the libname has been specified, tables from FDB can be loaded using the data step, using: “set <libname>.<table name>” For example, to load the table “RPRD0_PRODUCT”: data test; set rxdata.RPRD0_PRODUCT; run; Details: <name> – this is simply the name of the library, it can be set to any allowable library name. Do not change the following parameters unless the Mysql configuration is changed: mysql – this tell SAS that it is trying to connect to a Mysql sever. User – Currently the Mysql server has one user, shouston. Password – This is the current password for user, shouston. Database – This is the name of the database where the FDB drug data is stored. Server – Name of server where the database is located. Currently FDB database is on sasser1. Please note that if the user, password, database name, or server name are changed those changes will need to be reflected in the libname statement above. Alternate to sas program, type at prompt: >mysql –u shouston –p –h sasser1 FDB Password houstonwehaveaproblem Then this comes up: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 22 Server version: 5.5.56-MariaDB MariaDB Server Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [FDB]>\h List of all MySQL commands: Note that all text commands must be first on line and end with ';' ? (\?) Synonym for `help'. clear (\c) Clear the current input statement. connect (\r) Reconnect to the server. Optional arguments are db and host. delimiter (\d) Set statement delimiter. edit (\e) Edit command with $EDITOR. ego (\G) Send command to mysql server, display result vertically. exit (\q) Exit mysql. Same as quit. go (\g) Send command to mysql server. help (\h) Display this help. nopager (\n) Disable pager, print to stdout. notee (\t) Don't write into outfile. pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. print (\p) Print current command. prompt (\R) Change your mysql prompt. quit (\q) Quit mysql. rehash (\#) Rebuild completion hash. source (\.) Execute an SQL script file. Takes a file name as an argument. status (\s) Get status information from the server. system (\!) Execute a system shell command. tee (\T) Set outfile [to_outfile]. Append everything into given outfile. use (\u) Use another database. Takes database name as argument. charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. warnings (\W) Show warnings after every statement. nowarning (\w) Don't show warnings after every statement. For server side help, type 'help contents' .