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

1

7

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??

Maharajah answered 16/7, 2014 at 6:42 Comment(0)
B
1

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();
    }
Bed answered 20/12, 2014 at 9:19 Comment(3)
In this method we use sas code in java code. I was trying to use the API to get this done rather than writing some SAS code.Maharajah
I just reviewed the latest SAS IntTech Java API and other than working with options and formats, I don't see anything to work with macro variables directly (I assume macro vars, not pdv vars were what you were looking for). It's not native to the SAS api but you could build up a class to wrap the otherwise sas based approach. Given how it communicates under the covers, this is what would effectively be passing over the wire even if SAS provided the method. Otherwise, sorry I couldn't help more directly but perhaps others might find this useful as a quick way to solve a common problem.Bed
I contacted the SAS support. They said they can't help as the their API does not have anything as such. Right now i'm doing it through SAS code in JAVA.Maharajah

© 2022 - 2024 — McMap. All rights reserved.