Set up SAS to use the SAS/LabKey Interface

The LabKey/SAS client library is a set of SAS macros that retrieve data from an instance of LabKey Server as SAS data sets. The SAS macros use the Java Client Library to send, receive, and process requests to the server.

Configure your SAS installation to use the SAS/LabKey interface:

  1. Install SAS
  2. Retrieve the latest ClientAPI-SAS.zip file (e.g., LabKey15.3-41022.16-ClientAPI-SAS.zip) from the "All Downloads" tab on the LabKey Server download page.
  3. Extract this file to a local directory (these instructions assume "c:\sas"). The directory should contain a number of .jar files (the Java client library and its dependencies) and 12 .sas files (the SAS macros).
  4. Open your default SAS configuration file, sasv9.cfg (e.g., in c:\Program Files\SASHome\x86\SASFoundation\9.3\nls\en)
  5. In the -SET SASAUTOS section, add the path to the SAS macros to the end of the list (e.g., "C:\sas")
  6. Configure your Java Runtime Environment (JRE) based on your SAS version:
  • Instructions for SAS 9.1.x (NO LONGER SUPPORTED)
    • SAS 9.1.x installs a 1.4 JRE; you must install a 7.0 JRE and change -Dsas.jre.home= to point to it
    • In the JREOPTIONS section of sasv9.cfg, add -Dsas.app.class.path= full paths to all .jar files separated by ;
  • Instructions for SAS 9.2 (NO LONGER SUPPORTED)
    • SAS 9.2 installs a 5.0 JRE; you must install a 7.0 JRE and change -Dsas.jre.home= to point to it
    • Set the system CLASSPATH environment variable to the full paths to all jar files separated by ;
  • Instructions for SAS 9.3
    • Install the SAS update TS1M2, in order to run it with Java 7, instead of Java 6 (which is the default for SAS 9.3)
    • Near the top of sasv9.cfg, add -set classpath "<full paths to all .jar files separated by ; (on Windows) or : (on Mac)>" (see below)
  • Instructions for SAS 9.4
    • No configuration of the Java runtime is necessary on SAS 9.4 since it runs a private Java 7 JRE, installed in the SASHOME directory
    • Near the top of sasv9.cfg, add -set classpath "<full paths to all .jar files separated by ; (on Windows) or : (on Mac)>"; (see below)
Example Java classpath for Windows:

-set classpath "C:\sas\commons-codec-1.6.jar;C:\sas\commons-logging-1.1.3.jar;C:\sas\fluent-hc-4.3.5.jar;C:\sas\httpclient-4.3.5.jar;C:\sas\httpclient-cache-4.3.5.jar;
C:\sas\httpcore-4.3.2.jar;C:\sas\httpmime-4.3.5.jar;C:\sas\json_simple-1.1.jar;C:\sas\opencsv-2.0.jar;C:\sas\labkey-client-api-15.2.jar"

Example Java classpath for Mac:

-set classpath "/sas/commons-codec-1.6.jar:/sas/commons-logging-1.1.3.jar:/sas/fluent-hc-4.3.5.jar:/sas/httpclient-4.3.5.jar:/sas/httpclient-cache-4.3.5.jar:
/sas/httpcore-4.3.2.jar:/sas/httpmime-4.3.5.jar:/sas/json_simple-1.1.jar:/sas/opencsv-2.0.jar:/sas/labkey-client-api-15.2.jar"

Configure LabKey Server and run the test script:

  1. On your local version of LabKey Server, configure a list called "People" in your home folder and import demo.xls to populate it with data
  2. Configure your .netrc or _netrc file in your home directory. For further information, see: Create a .netrc or _netrc file.
  3. Run SAS
  4. Execute "proc javainfo; run;" in a program editor; this command should display detailed information about the java environment in the log. Verify that java.version matches the JRE you set above.
  5. Load demo.sas
  6. Run it

Related Topics

External SAS Data Sources.

Discussion

previousnext
 
expand all collapse all