Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert variables into SAS using JAVA (IOM Bridge). Should i use CORBA stubs and JDBC or is there any other alternative?

Tags:

java

jdbc

sas

corba

This is part of my code snippet

WorkspaceConnector connector = null;
WorkspaceFactory workspaceFactory = null;
String variableListString = null;
Properties sasServerProperties = new Properties();
sasServerProperties.put("host", host);
sasServerProperties.put("port", port);
sasServerProperties.put("userName", userName);
sasServerProperties.put("password", password);
Properties[] sasServerPropertiesList = { sasServerProperties };
workspaceFactory = new WorkspaceFactory(sasServerPropertiesList, null, logWriter);
connector = workspaceFactory.getWorkspaceConnector(0L);
IWorkspace sasWorkspace = connector.getWorkspace();
ILanguageService sasLanguage = sasWorkspace.LanguageService();
//send variable list string
//continued

I need to send the "variableListString" to the SAS server through IOM bridge. Java SAS API doesn't give explicit ways to do it. Using CORBA and JDBC is the best way to do it?? Give me a hint how to do it. Is there any alternative method to do it??

like image 896
Tejus Prasad Avatar asked Jul 16 '14 06:07

Tejus Prasad


1 Answers

This was asked a while back but useful in case anyone is still looking to do the same.
One way to do this is build a string of sas code and submit it to the server. We use this method for setting up variables on the host for the connected session. You can also use this technique to include sas code using code like %include "path to my code/my sas code.sas";:

...continue from code in the question...

langService = iWorkspace.LanguageService();
    StringBuilder sb = new StringBuilder();
    sb.append("%let mysasvar=" + javalocalvar);
    ... more variables
    try {
        langService.Submit(sb.toString());
    } catch (GenericError e) {
        e.printStackTrace();
    }
like image 191
Tim Cederquist Avatar answered Sep 24 '22 02:09

Tim Cederquist