Java 如何在SAS 9.4中获得类似OLAPDataSetInterface的对象
我需要得到一个像OLAPDataSetInterface这样的对象,但不使用OLAP服务器 我曾经用过:Java 如何在SAS 9.4中获得类似OLAPDataSetInterface的对象,java,sas,Java,Sas,我需要得到一个像OLAPDataSetInterface这样的对象,但不使用OLAP服务器 我曾经用过: //Connect to OLAP server OLAPDataSetInterface cube = objectInSession.getOlapDataSet(); //Get the info cube.execute("query_mdx"); 我尝试使用DataSetInterface,但不起作用: com.sas.sasserver.dataset.DataSetInter
//Connect to OLAP server
OLAPDataSetInterface cube = objectInSession.getOlapDataSet();
//Get the info
cube.execute("query_mdx");
我尝试使用DataSetInterface,但不起作用:
com.sas.sasserver.dataset.DataSetInterface ds = null;
//Getting my temporary table
ds.setDataSet("WORK.my_table");
我做了以下工作:
//BBDD connector
WorkspaceConnector connector = factory.getWorkspaceConnector(0L);
IWorkspace workspace = connector.getWorkspace();
ILanguageService ls = workspace.LanguageService();
//This creates my temporary table in the library WORK (WORK.my_table)
String stmt = "%include \"/saswork/MY_PROGRAM.sas\" ;";
ls.Submit(stmt);
com.sas.sasserver.dataset.DataSetInterface ds = null;
//ds = ...
这是用C#编写的,但应该有助于理解数据集检索过程。我不使用SAS OLAP,因此无法告诉您如何使用该项
public string GetDataSet(string sasDirectory, string dataset)
{
Common.Log($"Getting SAS dataset ({dataset}) at {sasDirectory}");
DataTable dt = new DataTable(dataset);
try
{
using (var cn = new OleDbConnection($@"Provider=SAS.LocalProvider; Data Source={sasDirectory}"))
{
cn.Open();
var cmd = cn.CreateCommand();
cmd.CommandType = CommandType.TableDirect;
cmd.CommandText = dataset;
var sas = new OleDbDataAdapter(cmd);
var ds = new System.Data.DataSet();
sas.Fill(ds, dataset);
dt = ds.Tables[0];
Common.Log($"SAS dataset loaded.");
}
}
catch (Exception ex)
{
string errMessage = "Unable to get the SAS dataset. Library: " + sasDirectory + ", DataSet: " + dataset + ", " +
ex.TargetSite.Name;
Common.Log($"SAS Error in {MethodBase.GetCurrentMethod().Name}", MessageType.Error, ex);
}
return dt.ToCsv('\t');
}