The following code uses
the SQL pass-through facility to pass an MDX statement to a Microsoft
SQL Server Decision Support Services (DSS) Cube. The provider used
is the Microsoft OLE DB for OLAP provider named MSOLAP.
proc sql noerrorstop;
connect to oledb (provider=msolap prompt=yes);
select * from connection to oledb
( MDX::select {[Measures].[Units Shipped],
[Measures].[Units Ordered]} on columns,
NON EMPTY [Store].[Store Name].members on rows
from Warehouse );
See the Microsoft Data
Access Components Software Developer's Kit for details about MDX
syntax.
The CONNECT statement
requests prompting for connection information, which facilitates the
connection process (especially with provider properties). The MDX::
prefix identifies the statement within the parentheses that follows
the MDX statement syntax, and is not an SQL statement that is specific
to OLAP. Partial output from this query might look like this:
Store Units Shipped Units Ordered
Store6 10,647 11,699
Store7 24,850 26,223
. . .
. . .
. . .
You can use the same
MDX statement with the MDX_DESCRIBE:: identifier to see the full description
of each column:
proc sql noerrorstop;
connect to oledb (provider=msolap prompt=yes);
select * from connection to oledb
( MDX_DESCRIBE::select {[Measures].[Units Shipped],
[Measures].[Units Ordered]} on columns,
NON EMPTY [Store].[Store Name].members on rows
from Warehouse );
The next example creates
a view of the OLAP data, which is then accessed using the PRINT procedure:
proc sql noerrorstop;
connect to oledb(provider=msolap
props=('data source'=sqlserverdb
'user id'=myuserid password=mypassword));
create view work.myview as
select * from connection to oledb
( MDX::select {[MEASURES].[Unit Sales]} on columns,
order(except([Promotion Media].[Media Type].members,
{[Promotion Media].[Media Type].[No Media]}),
[Measures].[Unit Sales],DESC) on rows
from Sales )
;
proc print data=work.myview;
run;
In this example, full
connection information is provided in the CONNECT statement, so the
user is not prompted. The SQL view can be used in other PROC SQL statements,
the DATA step, or in other procedures, but you cannot modify (that
is, insert, update, or delete a row in) the view's underlying multidimensional
data.