Data is generated internally by the script via DATA STEPs, using the `ranuni` function to create random values. No external files are read.
1 Code Block
Global Options and %put macros
Explanation : This block configures the network encryption algorithm to SSL. It then displays information about the local SAS client environment using `%put` macros and various system variables and macro functions (`&sysuserid`, `&syshostname`, `%sysget`). This allows verification of the current SAS session's configuration and identity.
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 initializes macro variables (`_sessionName`, `_sessionType`, `_namespace`, `_casserver`) used to specify the details for connecting to a CAS server. The `cas` command is then used to establish a named CAS session, specifying the CAS controller host, port, and session options, such as metrics collection. This prepares the environment for CAS code execution.
Copied!
/* CAS session */
%let _sessionName=&sysuserid;
%let _sessionType=studio;
%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);
1
/* CAS session */
2
%let _sessionName=&sysuserid;
3
%let _sessionType=studio;
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);
3 Code Block
SAS/CONNECT Session Management
Explanation : This block prepares and establishes a SAS/CONNECT connection. It defines the `host` macro variable with the address and port of the remote connect server. The `SIGNON` command is then used to connect to the remote server using credentials (`geladm`, `lnxsas`). `%syslput` is used to send the value of `_sessionType` to the remote environment, making it available for subsequent `rsubmit` blocks.
Explanation : This block, executed on the remote server via `rsubmit`, displays detailed information about the SAS server environment. It uses the same system variables and macro functions as the client block to provide an overview of the remote server's user, process, and environment.
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 creates a local SAS dataset named `localstudio` (using the value of `_sessionType`). It generates 100 million observations, each with two variables: `i` (a counter) and `j` (a random numeric value generated by the `ranuni` function). This block illustrates the creation of large in-memory data on the local session.
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;
6 Code Block
DATA STEP (Remote) and %sysrput Macro Data
Explanation : Executed on the remote server via `rsubmit`, this block first displays the value of the `_sessionTypeRemote` macro. It then creates a large remote SAS dataset named `remotestudio` (using the value of `_sessionTypeRemote`) with 100 million observations and random values similar to the local block. Finally, `%sysrput` is used to retrieve the path of the remote server's work directory (`work`) and store it in the `rsaswork` macro of the local session, allowing this path to be referenced after `endrsubmit`.
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;
7 Code Block
LIBNAME
Explanation : This block displays the value of the `rsaswork` macro (the remote work directory path) and then assigns a SAS library (`libname`) named `rsaswork`. This library is linked to the remote path (`&rsaswork`) and uses the SAS/CONNECT session (`server=host`) to access the data residing there. This allows interaction with remote server data from the local session.
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 with SAS Viya, mastering the interplay between the Client, Remote Compute, and CAS (Cloud Analytic Services) is the key to scalable performance. This script effectively demonstrates a hybrid architecture where tasks are distributed based on their specific strengths: local coordination, remote task offloading via RSUBMIT, and massively parallel processing potential in CAS »
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.