我需要获取一个像OLAPDataSetInterface这样的对象,但不使用OLAP服务器。
我曾经用过:
//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');
}
关于java - 如何在SAS 9.4中获取类似OLAPDataSetInterface的对象,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58075168/