Published on :

Management and Connectivity to the SAS/SHARE Server

This code is also available in: Deutsch Español Français
Attention : This code requires administrator privileges.
This document compiles several SAS© Viya 4 code examples illustrating the use of SAS©/SHARE. It covers configuring a Windows services file (non-SAS© section), starting a SAS©/SHARE server instance with PROC SERVER, stopping this server with PROC OPERATE, establishing connections to remote libraries via LIBNAME, and executing remote SQL queries via the SQL Pass-Through mechanism. The focus is on interfacing with a remote SAS©/SHARE server for data management and access.
Data Analysis

Type : MIXTE


The script uses the SASHELP.RETAIL library, which is a standard SAS example data library, accessible via a remote SAS/SHARE server. Server connection and operation parameters (IDs, passwords) are defined directly in the code.

1 Code Block
PROC SERVER
Explanation :
This code block starts a SAS/SHARE server instance. It assigns it the identifier 'shr1', configures passwords for the administrator ('oapw=system') and the user ('uapw=user'), and enforces mandatory authentication for connections.
Copied!
1 
2PROC SERVER id=shr1 oapw=system uapw=user
3authenticate=required;
4RUN;
5 
2 Code Block
PROC OPERATE
Explanation :
This code block is used to stop the SAS/SHARE server. It targets the server with the identifier 'shr1', uses a system administrator password ('sapw=system'), and prompts the user to provide their UID during execution ('uid=_prompt'). The 'stop server;' command initiates the shutdown.
Copied!
1 
2PROC OPERATE serverid=shr1 sapw=system uid=_prompt;
3stop server;
4RUN;
5 
3 Code Block
LIBNAME et PROC PRINT
Explanation :
This block first establishes a connection to a remote SAS library. The LIBNAME statement 'SHARED' points to the 'SASHELP' library on the SAS/SHARE server 'hrothgar.shr1', requiring a user password. Then, PROC PRINT is used to display a subset of the 'RETAIL' data from this remote library, filtering years after 1990 and selecting specific variables for the report.
Copied!
1LIBNAME SHARED slibref=SASHELP server=hrothgar.shr1
2sapw=user passwd=_prompt_;
3 
4PROC PRINT DATA=SHARED.RETAIL;
5title "Retail Sales Total by Month: 1991-1994";
6where YEAR gt 1990;
7var MONTH SALES;
8id YEAR;
9RUN;
4 Code Block
PROC SQL (Pass-Through)
Explanation :
This block uses PROC SQL to execute a SQL Pass-Through query on the remote SAS/SHARE server 'hrothgar.shr1'. It connects to the server and executes a subquery that selects the year, month, and sum of sales (renamed 'Total Sales') from the SASHELP.RETAIL table, grouped by year and month. The result of this remote query is then selected and displayed by PROC SQL locally.
Copied!
1PROC SQL;
2 
3connect to remote
4(server=hrothgar.shr1 sapw=user passwd=_prompt_);
5 
6select * from connection to remote
7(select YEAR, MONTH, sum(SALES)
8FORMAT=dollar12. label='Total Sales'
9from SASHELP.RETAIL
10group BY YEAR, MONTH);
11QUIT;
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 : Copyright (c) 1993-1999 Microsoft Corp.


Banner
Expert Advice
Expert
Simon
Expert SAS et fondateur.
« Always utilize the _prompt_ or _prompt_ keyword for password variables. This ensures compliance with security auditing standards by keeping sensitive credentials out of log files and source code. »