CHAPTER 7 Examples of Combining Compute Services and Data Transfer Services

Similar documents
Using Data Transfer Services

Using Cross-Environment Data Access (CEDA)

Introduction. LOCK Statement. CHAPTER 11 The LOCK Statement and the LOCK Command

APPENDIX 2 Customizing SAS/ASSIST Software

SAS Support for TELNET on Windows

Storing and Reusing Macros

Examples That Use Remote Objecting

SAS I/O Engines. Definition. Specifying a Different Engine. How Engines Work with SAS Files CHAPTER 36

Locking SAS Data Objects

Windows: SPX Access Method

OS/2: SPX Access Method

The SERVER Procedure. Introduction. Syntax CHAPTER 8

Permission Program. Support for Version 6 Only. Allowing SAS/SHARE Client Access to SAS Libraries or Files CHAPTER 40

SAS File Management. Improving Performance CHAPTER 37

Creating and Executing Stored Compiled DATA Step Programs

Using the SQL Editor. Overview CHAPTER 11

SAS/ASSIST Software Setup

SAS Catalogs. Definition. Catalog Names. Parts of a Catalog Name CHAPTER 32

OS/390 Platform Examples

APPENDIX 4 Migrating from QMF to SAS/ ASSIST Software. Each of these steps can be executed independently.

Chapter 28 Saving and Printing Tables. Chapter Table of Contents SAVING AND PRINTING TABLES AS OUTPUT OBJECTS OUTPUT OBJECTS...

Data Set Options. Specify a data set option in parentheses after a SAS data set name. To specify several data set options, separate them with spaces.

CHAPTER 5 Macintosh: TCP/IP Access Method

Using MDP Extensions. What Is the Multidimensional Data Provider? CHAPTER 3

UNIX Platform Error Messages

DBLOAD Procedure Reference

Optimizing System Performance

Data Representation. Variable Precision and Storage Information. Numeric Variables in the Alpha Environment CHAPTER 9

Chapter 3 Managing Results in Projects. Chapter Table of Contents

SAS Data Libraries. Definition CHAPTER 26

Graphics. Chapter Overview CHAPTER 4

UNIX Spawner Program. Starting the UNIX Spawner Program CHAPTER 36

OpenVMS Operating Environment

Chapter 6 Creating Reports. Chapter Table of Contents

Tasks Menu Reference. Introduction. Data Management APPENDIX 1

CHAPTER 13 Importing and Exporting External Data

External Files. Definition CHAPTER 38

CHAPTER 7 Using Other SAS Software Products

Formats. Formats Under UNIX. HEXw. format. $HEXw. format. Details CHAPTER 11

10 The First Steps 4 Chapter 2

Introduction. Getting Started with the Macro Facility CHAPTER 1

Macro Facility. About the Macro Facility. Automatic Macro Variables CHAPTER 14

Introduction. Understanding SAS/ACCESS Descriptor Files. CHAPTER 3 Defining SAS/ACCESS Descriptor Files

Chapter 25 PROC PARETO Statement. Chapter Table of Contents. OVERVIEW SYNTAX SummaryofOptions DictionaryofOptions...

from the source host, use the FTP put command to copy a file from the source host to the target host.

SAS/ACCESS Interface to R/3

Overview. CHAPTER 2 Using the SAS System and SAS/ ASSIST Software

The EXPLODE Procedure

What Is a Communications Access Method? CHAPTER 1 Using Communications Access Methods

SCL Arrays. Introduction. Declaring Arrays CHAPTER 4

Performance Considerations

Chapter 23 Animating Graphs. Chapter Table of Contents ANIMATING SELECTION OF OBSERVATIONS ANIMATING SELECTED GRAPHS...347

Introduction to MDDBs

This chapter is recommended primarily for server administrators.

CV2ODBC Procedure. Overview. CV2ODBC Procedure Syntax APPENDIX 4

SAS Component Language (SCL) Interface to Agent Services

QUEST Procedure Reference

SAS. IT Service Level Management 2.1: Migration Documentation

Choosing the Right Procedure

The GREMOVE Procedure

Chapter 23 Introduction to the OPTEX Procedure

Handling Exceptions. Introduction. Using the Program Halt Handler CHAPTER 10

The TRANTAB Procedure

DATA Step Debugger APPENDIX 3

The TIMEPLOT Procedure

SAS/CONNECT for SAS Viya 3.3: User s Guide

Informats. Informats Under UNIX. HEXw. informat. $HEXw. informat. Details CHAPTER 13

The GTESTIT Procedure

Installation Instructions for SAS/ACCESS Interface to SAP BW

SAS Web Infrastructure Kit 1.0. Overview

Chapter 14 Introduction to the FACTEX Procedure

The SAS Interface to REXX

Using SAS Files. Introduction CHAPTER 5

Administrator for Enterprise Clients: User s Guide. Second Edition

Defining Your Data Sources

Routing the SAS Log and SAS Procedure Output

SAS Data Integration Studio 3.3. User s Guide

SAS/ACCESS Data Set Options

SAS Clinical Data Integration 2.4

Loading Data. Introduction. Understanding the Volume Grid CHAPTER 2

Changes and Enhancements

SAS Drug Development 3.3_03. December 14, 2007

Enterprise Miner Software: Changes and Enhancements, Release 4.1

Alternative ODS HTML Statements for Running Examples in Different Operating Environments

Chapter 27 Saving and Printing Graphics

Chapter 2 User Interface Features. networks Window. Drawing Panel

Changes and Enhancements

The correct bibliographic citation for this manual is as follows: SAS Institute Inc Proc EXPLODE. Cary, NC: SAS Institute Inc.

Customizing Your SAS Session

SAS. Installation Guide Fifth Edition Intelligence Platform

A simplistic approach to Grid Computing Edmonton SAS Users Group. April 5, 2016 Bill Benson, Enterprise Data Scienc ATB Financial

SAS/FSP 9.2. Procedures Guide

Introduction. CHAPTER 3 Working in the SAS Windowing Environment

Batch Importing. Overview CHAPTER 4

Changes and Enhancements

Using Dynamic Data Exchange

Divide and Conquer Writing Parallel SAS Code to Speed Up Your SAS Program

The STANDARD Procedure

The G4GRID Procedure. Introduction APPENDIX 1

SAS IT Resource Management 3.3

Transcription:

55 CHAPTER 7 Examples of Combining Compute Services and Data Transfer Services Introduction 55 Example 1. Compute Services and Data Transfer Services Combined: Local and Remote Processing 56 Purpose 56 Program 56 Running the Program 57 Example 2. Compute Services and Data Transfer Services Combined: Sorting and Merging Data 58 Purpose 58 Program 58 Example 3. Compute Services and Data Transfer Services Combined: Macro Capabilities 59 Purpose 59 Program 59 Introduction If you need information from data that is stored on a remote system, and you do not want to move a copy of the data to the local system, then you can benefit from combining compute services and data transfer services. Reasons for not moving a copy of the data could include: 3 the amount of data is too large. 3 the data is frequently updated. 3 you want to avoid data duplication. Regardless of the motivation for reducing the amount of data that is transferred, incorporating compute services will achieve your goal. As Figure 7.1 on page 56 illustrates, compute services enable you to format and pre-process data into a subset or a summarized form on the remote system, prior to transferring the subsequent smaller amount of data to the local platform. This balances the use of CPU cycles between the local and remote systems and minimizes the amount of data contributing to network traffic.

56 Example 1. Compute Services and Data Transfer Services Combined: Local and Remote Processing 4 Chapter 7 Figure 7.1 Combined Compute and Data Transfer Services Processing Model Example 1. Compute Services and Data Transfer Services Combined: Local and Remote Processing Purpose The SAS/CONNECT statements SIGNON, SIGNOFF, RSUBMIT, and ENDRSUBMIT enable you to submit statements to a remote host from a session on the local host. You can include these statements in a SAS program and do both local and remote processing within a single SAS program. This program can be run in an interactive line-mode SAS session, in a non-interactive SAS session, or by including the program in a session that is running on your local host. In each case, the program executes statements on both the local host and the remote host. Program For example, suppose that you want to perform some processing on a remote host, download the resulting SAS data set, create a permanent data set on the local host, and print a report on the local host. The following example illustrates how to put all of these tasks into a single program. /* prepare to sign on */ u options comamid=netbios remote=netpc; v libname lhost c:\sales\reg1 ; /* sign on and download data set */ w signon; x rsubmit;

Examples of Combining Compute Services and Data Transfer Services 4 Running the Program 57 y libname rhost d:\dept12 ; proc sort data=rhost.master out=rhost.sales; where gross > 5000; by lastname dept; U proc download data=rhost.sales out=lhost.sales; V endrsubmit; W /* print data set in local session */ proc print data=lhost.sales; u Specify the COMAMID= and the REMOTE= system options in an OPTIONS statement. These two system options define to the local session what type of link you want to establish to which remote host. v Define a libref for the SAS data library on the local session where the downloaded data set should be stored. w Sign on to the remote host. It is not necessary to include remote-session-id when you have defined the REMOTE= system option in a previous OPTIONS statement. Note: This connection is not using a script file. 4 x Send statements to the remote session for processing with the RSUBMIT statement. All statements are sent to the remote session until an ENDRSUBMIT statement is encountered. Although it is not necessary to include remote-session-id, using remote-session-id in the RSUBMIT statement clarifies which remote session should process a group of statements when more than one link is active. If you omit remote-session-id, the RSUBMIT statement submits the statements to the remote session that is most recently identified in a SIGNON or an RSUBMIT statement or a REMOTE= system option. y Define the libref for the SAS data library on the remote host. U The PROC DOWNLOAD step transfers the data from the library on the remote host (RHOST) to the library on the local host (LHOST). V The ENDRSUBMIT statement signals the end of the block of statements that is to be submitted to the remote session. Statements following the ENDRSUBMIT statement are processed by the local session. W The PROC PRINT step executes in the local session and reads the SAS data set that was downloaded in the PROC DOWNLOAD step. Running the Program You have several options for running this program: 3 Type and submit each line in a line-mode SAS session. All of the statements between the RSUBMIT and ENDRSUBMIT statements are sent to the remote host for processing. All other statements are processed on the local host.

58 Example 2. Compute Services and Data Transfer Services Combined: Sorting and Merging Data 4 Chapter 7 Note: When statements are submitted to the remote host, several statements may be grouped into a single packet of data sent to the remote host. Therefore, a line that is remote-submitted is not necessarily processed immediately after you enter it on the local host. 4 3 Build a file containing all of these statements and use a %INCLUDE statement to include the file in a line-mode session. The file is processed immediately. 3 Build a file containing all of these statements and run a non-interactive SAS job to process the statements as follows: sas file-containing-program Note: Refer to Chapter 23, Starting and Stopping SAS/CONNECT Software, on page 193 for more information about automatic logon scripts. 4 3 Build a file containing all of these statements and use an INCLUDE command to include the file. You must submit the included statements from the windowing environment. 3 Build a file and issue the SUBMIT command from the Explorer window. Example 2. Compute Services and Data Transfer Services Combined: Sorting and Merging Data Purpose In cases where the same remote data set needs to be manipulated by multiple local hosts, data transfer services can be used to distribute the subset of data that is needed by each local host. Each local host receives only the data it needs and uses its compute services to process that data in the local GUI. With this method, local hosts do not have to continually access the data set on the remote machine. Program The following SCL program fragment distributes a reservations data set from a remote host at a central office to local hosts at a number of franchise offices. The program enables distribution of reservations to a franchise office by using a WHERE statement to select the desired reservations. INIT: submit continue; signon atlanta; u rsubmit; libname mres "d:\counter"; libname backup "d:\counter\backup"; proc upload data=mres.reserv out=combine status=no; where origin="atlanta"; v proc sort data=combine; by resnum;

Examples of Combining Compute Services and Data Transfer Services 4 Program 59 w x proc copy in=mres out=backup; select reserv; data mres.reserv; update mres.reserv combine; by resnum; endrsubmit; signoff; endsubmit; u Upload all reservations for a particular location. v Sort uploaded data sets for merging. w Backup existing data set. x Merge new and existing data sets. Example 3. Compute Services and Data Transfer Services Combined: Macro Capabilities Purpose SAS/CONNECT is fully functional from within the macro facility. Both the UPLOAD and the DOWNLOAD procedures can update the macro variable SYSINFO and set it to a nonzero value when the procedure terminates due to errors. You can also use the %SYSRPUT macro statement on the remote host to send the value of the SYSINFO macro variable back to the local SAS session. Thus, you can submit a job to the remote host and test whether a PROC UPLOAD or a PROC DOWNLOAD step has successfully completed before beginning another step on either the remote host or the local host. Program Suppose that you have a transaction file on your local host and you want to upload it to the remote host, and then use it to update a master file. You can test the results of the PROC UPLOAD step on the remote host by checking the value of the SYSINFO macro variable. The SYSINFO macro variable can be used to determine if the transaction file was successfully uploaded. If successful, the master file is updated with the new information. If the upload was not successful, you receive a message that explains the problem. You can use the %SYSRPUT macro statement to send the return code from the remote host back to the local session. Your SAS session on the local host can test the results of the upload and, if it is successful, use the DATASETS procedure to archive the transaction data set. u libname trans local-sas-data-library ; libname backup local-sas-data-library ;

60 Program 4 Chapter 7 v rsubmit; w proc upload data=trans.current out=current; x y U V %sysrput upload_rc=&sysinfo; %macro update_employee; %if &sysinfo=0 %then %do; libname perm remote-sas-data-library ; data perm.employee; update perm.employee current; by employee_id; %end; %else %put ERROR: UPLOAD of CURRENT failed. Master file was not updated.; %mend update_employee; %update_employee; endrsubmit; W %macro check_upload; X %if &upload_rc=0 %then %do; at proc datasets lib=trans; copy out=backup; %end; %mend check_upload; ak %check_upload; u Associate a libref with the SAS data library that contains the transaction data set on the local host. v Send the PROC UPLOAD statement and the UPDATE_EMPLOYEE macro to the remote host for execution. w Because a single-level name for the OUT= argument is specified, the PROC UPLOAD step stores CURRENT in the default library (usually WORK) on the remote host. x If the PROC UPLOAD step successfully completes, the SYSINFO macro variable is set to 0. The %SYSRPUT macro statement creates the UPLOAD_RC macro variable on the local host and puts the value that is stored in the SYSINFO macro variable into UPLOAD_RC. The UPLOAD_RC macro variable is passed to the local host and can be tested to determine if the PROC UPLOAD step was successful. y Tests the SYSINFO macro variable on the remote host. If the PROC UPLOAD step is successful, the transaction data set is used to update the master data set. U If the SYSINFO macro variable is not set to 0, the PROC UPLOAD step has failed, and the remote host sends messages to the SAS log (which appear in the local SAS session) notifying you that the step has failed. V Executes the UPDATE_EMPLOYEE macro on the remote host. W The CHECK_UPLOAD macro is executed on the local host because it follows the ENDRSUBMIT statement.

Examples of Combining Compute Services and Data Transfer Services 4 Program 61 X Tests the value of the UPLOAD_RC macro variable created by the %SYSRPUT macro statement on the remote host to see if the PROC UPLOAD step was successful. at When the transaction data set has been successfully uploaded and added to the master data set, the transaction file can be archived on the local host by using the COPY statement in the DATASETS procedure. ak Executes the CHECK_UPLOAD macro on the local host.

62 Program 4 Chapter 7

The correct bibliographic citation for this manual is as follows: SAS Institute Inc., SAS/ CONNECT User s Guide, Version 8, Cary, NC: SAS Institute Inc., 1999. pp. 537. SAS/CONNECT User s Guide, Version 8 Copyright 1999 by SAS Institute Inc., Cary, NC, USA. ISBN 1 58025 477 2 All rights reserved. Printed in the United States of America. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, SAS Institute Inc. U.S. Government Restricted Rights Notice. Use, duplication, or disclosure of the software by the government is subject to restrictions as set forth in FAR 52.227 19 Commercial Computer Software-Restricted Rights (June 1987). SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513. 1st printing, September 1999 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. IBM, AIX, DB2, OS/2, OS/390, RS/6000, System/370 TM, and System/390 are registered trademarks or trademarks of International Business Machines Corporation. ORACLE is a registered trademark or trademark of Oracle Corporation. indicates USA registration. Other brand and product names are registered trademarks or trademarks of their respective companies. The Institute is a private company devoted to the support and further development of its software and related services.