Hi @barbe1lj ,
You cab try the following macro
/**
*************************************************************************
* Lists and Closes All/Cube Specific Active Session on the specified OLAP
* Server.
* <br><br>Usage Example:<br>
* %olap_closeSessions(p_host=
* ,p_userid=
* ,p_password=
* ,p_port=5451
* ,p_cube=_ALL_);<br>
*
* @param p_host SAS OLAP Server Host Name network IP address
* @param p_userid Registered SAS Metadata User ID to use when
* logging into the OLAP Server
* @param p_password Registered SAS Metadata Password. Please use
* Encrypted password.
* @param p_port TCP/IP Port used by the SAS OLAP Server Process
* Default:5451
* @param p_cube SAS OLAP Cube Name being used
*
*************************************************************************
*/
%MACRO olap_closeSessions(
p_host
,p_userid=
,p_password=
,p_port=5451
,p_cube=_ALL_
);
%local l_closeStmt;
%let l_closeStmt=;
/* Assign a Filename and redirect the SAS log to it */
FILENAME outlog TEMP;
PROC PRINTTO LOG=outlog NEW; RUN;
/* Get a list of all Active Sessions on the OLAP Server */
PROC OLAPOPERATE;
CONNECT HOST="&p_host" PORT=&p_port USERID="&p_userid"
PASSWORD="&p_password";
%if (%superq(p_cube) = _ALL_) %then
%do;
LIST SESSIONS;
%end;
%else
%do;
LIST SESSIONS CUBE="&p_cube";
%end;
RUN;
/* Redirect the log back to the original log file */
PROC PRINTTO LOG=log; RUN;
/* Get Active Sessions on the OLAP Server */
DATA WORK.SESSIONS (KEEP=ID);
INFILE outlog TRUNCOVER;
LENGTH text $256 ID $71;
INPUT text $ &;
IF SUBSTR(text,1,10) = "Session ID" THEN
DO;
ID = SCAN(text,3,' ');
output;
END;
RUN;
PROC SQL NOPRINT;
SELECT "CLOSE SESSION '"||STRIP(ID)||"';"
INTO :l_closeStmt separated by ' '
FROM WORK.SESSIONS ;
QUIT;
%put l_closeStmt=%superq(l_closeStmt);
%put sqlobs=&sqlobs;
/* Close All Active Sessions on the OLAP Server if there were any */
%if (&SQLOBS GT 0) %then
%do;
PROC OLAPOPERATE;
CONNECT HOST="&p_host" PORT=&p_port USERID="&p_userid"
PASSWORD="&p_password";
&l_closeStmt
RUN;
%PUT "NOTE: &SQLOBS SAS OLAP Server sessions were closed.";
%end;
PROC DATASETS LIB=work NOLIST; DELETE sessions; RUN; QUIT;
%MEND olap_closeSessions;
You can use the sasadm@saspw user credentials to list and close all active sessions, or a specific session for a specific cube.
Hope this helps,
Ahmed