Create SAS Data Sets w/o SAS
Scope:
Create output in SAS7BDAT (closed binary format for
passionate SAS practitioners and experts without installing Base SAS product
from SAS Programming Institute.
Carolina S-JDBC Driver:
Dulles Research – A Virginia based private company offer
“Carolina S-JDBC” JDBC driver that replace the need for Base SAS license.
License constraints: (Carolina S-JDBC Driver Download,
2016)
Annual subscription is $995.00 for a single instance of application server.
Quote can be requested from enterprise wide installation. Free for
non-commercial use.
http://www.dullesresearch.com/sjdbc-download/
Solution:
Connection
connection = DriverManager.getConnection(
"jdbc:carolina:v2:libnames=
A S-JDBC license is required to use
the driver and SAS7BDAT file can be created very easily using general JDBC SQL
Statements.
Program:
Class.forName("com.dullesopen.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection(
"jdbc:carolina:v2:libnames=(data1='c:/gitwork/sas1');");
try {
Statement statement = connection.createStatement();
statement.execute("CREATE TABLE data1.event " +
"(e CHAR(5) label='Event Type', " +
"n DOUBLE PRECISION, " +
"d DATE, " +
"t TIME, " +
"dt TIMESTAMP)");
PreparedStatement preparedStatement = connection.prepareStatement(
"INSERT INTO data1.event (e, n, d, t, dt) " +
"VALUES (?, ?, ?, ?, ? )");
preparedStatement.setString(1, "a");
preparedStatement.setDouble(2, 10);
preparedStatement.setDate(3, Date.valueOf("2014-02-28"));
preparedStatement.setTime(4, Time.valueOf("05:27:43"));
preparedStatement.setTimestamp(5, Timestamp.valueOf("2014-02-28 14:43:57.678"));
preparedStatement.execute();
preparedStatement.setString(1, "b");
preparedStatement.setDouble(2, 11);
preparedStatement.setDate(3, null);
preparedStatement.setNull(4, Types.TIME);
preparedStatement.setNull(5, Types.TIMESTAMP);
preparedStatement.execute();
preparedStatement.close();
connection.commit();
} finally {
connection.close();
}
Alternatives:
References:
Carolina S-JDBC Driver Download. (2016, October 6). Retrieved from Dulles Research:
http://www.dullesresearch.com/sjdbc-download/

Comments
Post a Comment