Compiling a SAS Macro from Java

Reply
New Contributor
Posts: 3

Compiling a SAS Macro from Java

Hello.

I'm writing a Java application that I'd like to compile SAS macros from.

I'm thinking that I'm going to have to do some shell programming in the form code, but am not sure where to start.

Any assistance would be appreciated.

Thanks

dd

New Contributor
Posts: 3

Re: Compiling a SAS Macro from Java

The following is untested

import com.sas.iom.WorkspaceConnector;

import com.sas.iom.WorkspaceFactory;

import com.sas.iom.SAS.IWorkspace;

import java.util.Properties;

import com.sas.iom.SAS.ILanguageService;

import com.sas.iom.SAS.ILanguageServicePackage.CarriageControlSeqHolder;

import com.sas.iom.SAS.ILanguageServicePackage.LineTypeSeqHolder;

import com.sas.iom.SASIOMDefs.StringSeqHolder;

public class talkExample {

public static void main(String[] args) throws Exception {

Properties iomServerProperties = new Properties();

iomServerProperties.put("host","xxxxxxx");

iomServerProperties.put("port","xxxx");

iomServerProperties.put("userName","xxxxxx");

iomServerProperties.put("password","xxxxxxxx");

Properties[] serverList = {iomServerProperties};

WorkspaceFactory wFactory = new WorkspaceFactory(serverList,null,null);

WorkspaceConnector connector = wFactory.getWorkspaceConnector(0L);

IWorkspace sasWorkspace = connector.getWorkspace();

ILanguageService sasLanguage = sasWorkspace.LanguageService();

String inStr  = "%macro jmstore(pathname=);";

       inStr += "%if %nrbquote(&pathname) = %then %do;";

       inStr += "  %let msg=Parameter Missing (PATHNAME);";

       inStr += "  %goto err;";

       inStr += "%end;";

       inStr += "%else %do;";

       inStr += "  libname _jmstor = ""&pathname"";";

       inStr += "  options mstored sasmstore=sasmacr;";

       inStr += "%macro my_stored_macro1(blah) / store des = 'This is my stored macro' ;";

       inStr += "%mend my_stored_macro1;";

       inStr += "%end;";

       inStr += "%err:";

       inStr += " %put ERROR: &msg;";

       inStr += "%mend compstor;";

       inStr += "%jmstore(pathname=/path/to/store)";

sasLanguage.Submit(inStr);

}

}

New Contributor
Posts: 3

Re: Compiling a SAS Macro from Java

Great..

What do I need to get to implement com.sas.iom.WorkspaceConnector?


SAS Drivers for JDBC 9.3?


thanks again!


doug

New Contributor
Posts: 3

Re: Compiling a SAS Macro from Java

When I add these import statements:

import com.sas.iom.WorkspaceConnector;  

import com.sas.iom.WorkspaceFactory;  

import com.sas.iom.SAS.IWorkspace;  

import com.sas.iom.SAS.ILanguageService;  

import com.sas.iom.SAS.ILanguageServicePackage.CarriageControlSeqHolder;  

import com.sas.iom.SAS.ILanguageServicePackage.LineTypeSeqHolder;  

import com.sas.iom.SASIOMDefs.StringSeqHolder;  

I get: The import com.sas.iom cannot be resolved

Trusted Advisor
Posts: 1,300

Re: Compiling a SAS Macro from Java

You need to license SAS Integration Technologies and setup an appropriate classpath.  SAS AppDev Studio (a customized version of eclipse) is a useful IDE for this work.

Ask a Question
Discussion stats
  • 4 replies
  • 327 views
  • 3 likes
  • 3 in conversation