Data is internally generated within the script using DATA STEPs that create two distinct tables (one local and one remote), each with 100 million observations and a random numeric variable.
1 Code Block
MACRO
Explanation : This block initializes the `NETENCRYPTALGORITHM` option to `SSL` for network security. It then displays various information about the local client execution environment, such as user ID, host name, process name and ID, and its mode. It also retrieves and displays the state of the `SASCLOUDNATIVE`, `TCPNOIPADDR`, and `SAS_SERVICES_URL` environment variables.
Copied!
OPTIONS NETENCRYPTALGORITHM=SSL;
%put ********** CLIENT ********;
%put My local user ID is: &sysuserid;
%put The local host name is: &syshostname;
%put The local process name is: &sysprocessname;
%put The local process ID is: &sysprocessid;
%put The local process mode is: &sysprocessmode;
%let SASCLOUDNATIVE_state="%sysget(SASCLOUDNATIVE)";
%put &SASCLOUDNATIVE_state;
%let TCPNOIPADDR_state="%sysget(TCPNOIPADDR)";
%put &TCPNOIPADDR_state;
%let ENVIRONMENT="%sysget(SAS_SERVICES_URL)";
%put &ENVIRONMENT;
Explanation : This block defines macro variables to configure a CAS session, including the session name, type, namespace, and CAS server. It then starts a CAS session with the specified parameters. Next, it defines the host for a SAS/CONNECT connection (with options for an internal ClusterIP or an external NodePort) and establishes a SAS/CONNECT session to the remote server using a defined user and password. Finally, it passes the `_sessionType` macro variable to the remote session via `%syslput`.
Copied!
/* CAS session */
%let _sessionName=&sysuserid;
%let _sessionType=batch;
%let _namespace=gelcorp;
%let _casserver=default;
/* Start a CAS session on the cas-shared-&_casserver CAS server */
cas &_sessionName._&_sessionType host="controller.sas-cas-server-&_casserver..&_namespace..svc.cluster.local" port=5570 sessopts=(metrics=true);
/* Connect session */
/* INTERNAL ClusterIP */
%let host=sas-connect-spawner 17551;
/* EXTERNAL NodePort */
* %let host=gelcorp.pdcesx03138.race.sas.com 30377;
SIGNON host user='geladm' pass='lnxsas';
%syslput _sessionTypeRemote=&_sessionType;
1
/* CAS session */
2
%let _sessionName=&sysuserid;
3
%let _sessionType=batch;
4
%let _namespace=gelcorp;
5
%let _casserver=default;
6
7
/* Start a CAS session on the cas-shared-&_casserver CAS server */
8
cas &_sessionName._&_sessionType host="controller.sas-cas-server-&_casserver..&_namespace..svc.cluster.local" port=5570 sessopts=(metrics=true);
Explanation : This block is executed on the remote server via `RSUBMIT`. It displays information similar to the client but for the remote server environment, such as user ID, host, process name and ID, and its mode. It also retrieves and displays the state of the `SASCLOUDNATIVE`, `TCPNOIPADDR`, and `SAS_SERVICES_URL` environment variables on the server.
Copied!
rsubmit;
%put ********** SERVER ********;
%put My remote user ID is: &sysuserid;
%put The remote host name is: &syshostname;
%put The remote process name is: &sysprocessname;
%put The remote process ID is: &sysprocessid;
%put The remote process mode is: &sysprocessmode;
%let SASCLOUDNATIVE_state="%sysget(SASCLOUDNATIVE)";
%put &SASCLOUDNATIVE_state;
%let TCPNOIPADDR_state="%sysget(TCPNOIPADDR)";
%put &TCPNOIPADDR_state;
%let ENVIRONMENT="%sysget(SAS_SERVICES_URL)";
%put &ENVIRONMENT;
endrsubmit;
Explanation : This DATA STEP block creates a SAS table named `localbatch` (where `&_sessionType` is 'batch') in the local work library. This table is generated with 100 million observations, each containing an index `i` and a variable `j` filled with random numbers.
Copied!
data local&_sessionType;
do i=1 to 100000000;
j=ranuni(1234);
output;
end;
run;
1
DATA local&_sessionType;
2
DO i=1 to 100000000;
3
j=ranuni(1234);
4
OUTPUT;
5
END;
6
RUN;
5 Code Block
DATA STEP / MACRO (via RSUBMIT) Data
Explanation : This block, executed via `RSUBMIT` on the remote server, first displays the remote session type. It then creates a SAS table named `remotebatch` in the remote server's work library, similar to the local table, with 100 million random observations. Finally, it uses `%sysrput` to return the path to the remote server's work library to the local session, stored in the `rsaswork` macro variable.
Copied!
rsubmit;
%put &_sessionTypeRemote;
data remote&_sessionTypeRemote;
do i=1 to 100000000;
j=ranuni(1234);
output;
end;
run;
%sysrput rsaswork=%sysfunc(pathname(work));
endrsubmit;
1
rsubmit;
2
%put &_sessionTypeRemote;
3
4
DATA remote&_sessionTypeRemote;
5
DO i=1 to 100000000;
6
j=ranuni(1234);
7
OUTPUT;
8
END;
9
RUN;
10
11
%sysrput rsaswork=%sysfunc(pathname(work));
12
endrsubmit;
6 Code Block
LIBNAME
Explanation : This block displays the path of the remote work library. It then uses a `LIBNAME` statement to create a `rsaswork` shortcut in the local SAS session, which points to the path of the remote work library (`&rsaswork`) using the SAS/CONNECT connection (`server=host`). This allows the local session to directly access data stored in the remote server's working directory.
Explanation : Executed on the remote server via `RSUBMIT`, this `DATA _NULL_` block uses the `CALL SLEEP` function to pause the remote session for 5 minutes (300 seconds). This is useful for keeping the session active, especially in batch processing environments where the session might otherwise terminate prematurely.
Copied!
rsubmit;
data _null_;
call sleep(5,60);
run;
endrsubmit;
1
rsubmit;
2
DATA _null_;
3
call sleep(5,60);
4
RUN;
5
endrsubmit;
8 Code Block
CAS / SAS/CONNECT
Explanation : This block ensures the clean closure of open sessions. It terminates the CAS session specified by `&_sessionName._&_sessionType` and uses `SIGNOFF _ALL_` to disconnect all active SAS/CONNECT sessions.
Copied!
* waitfor _all_;
/* Close both CAS and connect sessions */
cas &_sessionName._&_sessionType terminate;
signoff _all_;
1
* waitfor _all_;
2
3
4
/* Close both CAS and connect sessions */
5
cas &_sessionName._&_sessionType terminate;
6
signoff _all_;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
« When working in a cloud-native environment like SAS Viya, the ability to bridge Client, Remote SAS 9.4/Viya Compute, and CAS (Cloud Analytic Services) is essential for high-performance data processing. This script demonstrates a "distributed triangulation" approach: running local logic, offloading heavy compute to a remote spawner via RSUBMIT, and leveraging CAS for in-memory analytics. »
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.