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

Tejus Prasad
  • 6,322
  • 7
  • 47
  • 75

1 Answers1

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();
    }
Tejus Prasad
  • 6,322
  • 7
  • 47
  • 75
Tim Cederquist
  • 191
  • 3
  • 6
  • 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. – Tejus Prasad Dec 27 '14 at 22:08
  • 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. – Tim Cederquist Dec 29 '14 at 03:25
  • 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. – Tejus Prasad Jan 09 '15 at 05:56