Published on :
Performance CREATION_INTERNE

SAS/CONNECT Parallel Execution Demonstration

This code is also available in: Deutsch Español Français
This program illustrates the parallel processing technique by launching two SAS©/CONNECT sessions (sess1 and sess2). It uses the `wait=no` option in the `rsubmit` statement to simultaneously execute two `DATA _NULL_` steps, each containing a `sleep(10)` statement. The script measures the total execution time to prove that the tasks ran in parallel (total time < sum of individual times). Note: The code contains explicit references to the SAS© 9 Grid architecture (metadata options, `grdsvc_enable`) which would require adaptation for a native SAS© Viya 4 environment.
Data Analysis

Type : CREATION_INTERNE


No external data read. Usage of system functions (time, sleep) and macro-variables for testing logic.

1 Code Block
OPTIONS / MACRO
Explanation :
Definition of metadata server connection options (SAS 9 specific) and activation of the grid service to allow parallel submissions.
Copied!
1options
2 metaserver='meta.demo.sas.com'
3 metaport=8561
4 metaprotocol='bridge'
5 metauser='sasdemo'
6 metapass='password'
7 metarepository='Foundation'
8 metaconnect='NONE';
9 
10%let rc=%sysfunc(grdsvc_enable(_all_, server=SASApp));
2 Code Block
SAS/CONNECT
Explanation :
Capture of start time, initialization of the first remote session (sess1), and asynchronous submission (wait=no) of a 10-second wait task.
Copied!
1%let st_tm=%SYSFUNC(time(),time.);
2SIGNON sess1;
3rsubmit sess1 wait=no;
4 DATA _null_;
5 rc=sleep(10,1);
6 RUN;
7 %put Note: Sess1 waited 10 seconds;
8endrsubmit;
3 Code Block
SAS/CONNECT
Explanation :
Initialization of the second session (sess2) and asynchronous submission of an identical second wait task.
Copied!
1SIGNON sess2;
2rsubmit sess2 wait=no;
3 DATA _null_;
4 rc=sleep(10,1);
5 RUN;
6 %put Note: Sess2 waited 10 seconds;
7endrsubmit;
4 Code Block
SAS/CONNECT
Explanation :
Synchronization command waiting for all submitted tasks to complete (waitfor) followed by session closure.
Copied!
1waitfor _all_;
2SIGNOFF _all_;
5 Code Block
DATA STEP
Explanation :
Capture of end time and Data Step to calculate and display the total elapsed duration, validating parallelism.
Copied!
1%let en_tm=%SYSFUNC(time(),time.) ;
2DATA _null_;
3 st_tm="&st_tm"t;
4 en_tm="&en_tm"t;
5 int=intck('seconds',st_tm,en_tm);
6 put "Interval is " int "seconds.";
7RUN;
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.
Copyright Info : Author: Greg Wootton Date: 04DEC2018