Statements. Executable and Declarative Statements

Similar documents
OS/2: TELNET Access Method

Analyzing the Server Log

Chapter 2 The Data Table. Chapter Table of Contents

UNIX Operating Environment

Chapter 6 INTERVALS Statement. Chapter Table of Contents

9.1 SAS/ACCESS. Interface to SAP BW. User s Guide

DBF Chapter. Note to UNIX and OS/390 Users. Import/Export Facility CHAPTER 7

9.1 SAS. SQL Query Window. User s Guide

When to Move a SAS File between Hosts

From The Little SAS Book, Fifth Edition. Full book available for purchase here.

Chapter 5 Programming Statements. Chapter Table of Contents

Using Macros to Automate SAS Processing Kari Richardson, SAS Institute, Cary, NC Eric Rossland, SAS Institute, Dallas, TX

B) Mean Function: This function returns the arithmetic mean (average) and ignores the missing value. E.G: Var=MEAN (var1, var2, var3 varn);

Chapter 32 Histograms and Bar Charts. Chapter Table of Contents VARIABLES METHOD OUTPUT REFERENCES...474

Encryption Services. What Are Encryption Services? Terminology. System and Software Requirements APPENDIX 5

An Introduction to SAS/SHARE, By Example

SAS/IntrNet 9.4: Application Dispatcher

5. Crea+ng SAS Datasets from external files. GIORGIO RUSSOLILLO - Cours de prépara+on à la cer+fica+on SAS «Base Programming»

SAS. Cloud. Account Administrator s Guide. SAS Documentation

Scheduling in SAS 9.3

SAS 9.4 In-Database Products

Scheduling in SAS 9.4 Second Edition

SAS IT Resource Management 3.2

Chapter 25 Specifying Forecasting Models

SAS Business Data Network 3.1

Tales from the Help Desk 3: More Solutions for Simple SAS Mistakes Bruce Gilsen, Federal Reserve Board

Before You Begin... 2 Running SAS in Batch Mode... 2 Printing the Output of Your Program... 3 SAS Statements and Syntax... 3

Guide to SAS/AF Applications Development

SAS 9.4 Logging. Configuration and Programming Reference Second Edition. SAS Documentation

SAS/ACCESS 9.3 Interface to PC Files

SAS Credit Scoring for Banking 4.3

IBM Unica emessage Version 8 Release 6 February 13, User's Guide

Overview. NT Event Log. CHAPTER 8 Enhancements for SAS Users under Windows NT

SAS 9.3 Logging: Configuration and Programming Reference

SAS Marketing Automation 5.1. User s Guide

SAS University Edition: Installation Guide for Windows

Importing Excel Files Into SAS Using DDE Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA

SAS Guide to Applications Development

Technical Paper. Defining an ODBC Library in SAS 9.2 Management Console Using Microsoft Windows NT Authentication

Making the Output Delivery System (ODS) Work for You William Fehlner, SAS Institute (Canada) Inc., Toronto, Ontario

Technical Paper. Reading Delimited Text Files into SAS 9

SAS 9.4 PC Files Server

Communications Access Methods for SAS/CONNECT 9.3 and SAS/SHARE 9.3 Second Edition

SAS/IntrNet 9.3: Application Dispatcher

Guide to Operating SAS IT Resource Management 3.5 without a Middle Tier

How to test and debug an ASP.NET application

Reading Delimited Text Files into SAS 9 TS-673

Instant Interactive SAS Log Window Analyzer

SAS Visual Analytics 7.1 for SAS Cloud. Quick-Start Guide

SAS ODS HTML + PROC Report = Fantastic Output Girish K. Narayandas, OptumInsight, Eden Prairie, MN

Qlik REST Connector Installation and User Guide

Paper An Introduction to SAS PROC SQL Timothy J Harrington, Venturi Partners Consulting, Waukegan, Illinois

SAS University Edition: Installation Guide for Amazon Web Services

Quick Start to Data Analysis with SAS Table of Contents. Chapter 1 Introduction 1. Chapter 2 SAS Programming Concepts 7

SAS Add-In 2.1 for Microsoft Office: Getting Started with Data Analysis

Carl R. Haske, Ph.D., STATPROBE, Inc., Ann Arbor, MI

1. Base Programming. GIORGIO RUSSOLILLO - Cours de prépara+on à la cer+fica+on SAS «Base Programming»

User Installation Guide for SAS 9.1 Foundation for 64-bit Microsoft Windows

Accessing a Remote SAS Data Library. Transcript

Using FILEVAR= to read multiple external files in a DATA Step

SAS 9.4 Interface to Application Response Measurement (ARM)

OnDemand for Academics

AN INTRODUCTION TO MACRO VARIABLES AND MACRO PROGRAMS Mike S. Zdeb, New York State Department of Health

SAS University Edition: Installation Guide for Linux

List of FTP commands for the Microsoft command-line FTP client

Transferring vs. Transporting Between SAS Operating Environments Mimi Lou, Medical College of Georgia, Augusta, GA

Forms Printer User Guide

IBM i Version 7.2. Systems management Advanced job scheduler

SUGI 29 Applications Development

Initializing SAS Environment Manager Service Architecture Framework for SAS 9.4M2. Last revised September 26, 2014

Data Integrator. Pervasive Software, Inc B Riata Trace Parkway Austin, Texas USA

SAS. 9.3 Guide to Software Updates. SAS Documentation

Database Programming with PL/SQL: Learning Objectives

Enhancing the SAS Enhanced Editor with Toolbar Customizations Lynn Mullins, PPD, Cincinnati, Ohio

Oracle Database: SQL and PL/SQL Fundamentals

Customer Tips. Xerox Network Scanning HTTP/HTTPS Configuration using Microsoft IIS. for the user. Purpose. Background

You have got SASMAIL!

How to Install MediaWiki on Windows Server 2003

Grid Computing in SAS 9.4 Third Edition

New Features Guide. Adaptive Server Enterprise 15.7 SP50

IBM Tivoli Storage Manager for Databases Version Data Protection for Microsoft SQL Server Messages IBM

Paper Creating Variables: Traps and Pitfalls Olena Galligan, Clinops LLC, San Francisco, CA

The SET Statement and Beyond: Uses and Abuses of the SET Statement. S. David Riba, JADE Tech, Inc., Clearwater, FL

Performance Test Suite Results for SAS 9.1 Foundation on the IBM zseries Mainframe

ABSTRACT INTRODUCTION SAS AND EXCEL CAPABILITIES SAS AND EXCEL STRUCTURES

Producing Structured Clinical Trial Reports Using SAS: A Company Solution

Paper Hot Links: Creating Embedded URLs using ODS Jonathan Squire, C 2 RA (Cambridge Clinical Research Associates), Andover, MA

NEC Express5800 Series NEC ESMPRO AlertManager User's Guide

SAS Task Manager 2.2. User s Guide. SAS Documentation

µtasker Document FTP Client

SAS BI Dashboard 4.4. User's Guide Second Edition. SAS Documentation

SAS 9.4 Intelligence Platform

ABSTRACT INTRODUCTION

FTP Client Engine Library for Visual dbase. Programmer's Manual

SAS BI Dashboard 3.1. User s Guide

Tips and Tricks for Creating Multi-Sheet Microsoft Excel Workbooks the Easy Way with SAS. Vincent DelGobbo, SAS Institute Inc.

An Introduction to SASlFSP Software Terry Fain, RAND, Santa Monica, California Cyndie Gareleck, RAND, Santa Monica, California

Importing Excel File using Microsoft Access in SAS Ajay Gupta, PPD Inc, Morrisville, NC

Return of the Codes: SAS, Windows, and Your s Mark Tabladillo, Ph.D., MarkTab Consulting, Atlanta, GA Associate Faculty, University of Phoenix

WS_FTP Professional 12

Transcription:

79 CHAPTER 8 Statements Definition 79 DATA Step Statements 79 Executable and Declarative Statements 79 DATA Step Statements by Category 80 Global Statements 84 Definition 84 Global Statements by Category 84 Definition A SAS statement is a series of items that may include keywords, SAS names, special characters, and operators. All SAS statements end with a semicolon. A SAS statement either requests SAS to perform an operation or gives information to the system. This book covers two kinds of SAS statements: 3 those used in DATA step programming 3 those that are global in scope and can be used anywhere in a SAS program. The SAS Procedures Guide gives detailed descriptions of the SAS statements that are specific to each SAS procedure. The Complete Guide to the SAS Output Delivery System gives detailed descriptions of the Output Delivery System (ODS) statements. DATA Step Statements Executable and Declarative Statements DATA step statements are those that can appear in the DATA step. They can be either executable or declarative. Executable statements result in some action during individual iterations of the DATA step; declarative statements supply information to SAS and take effect when the system compiles program statements. The following tables show the SAS executable and declarative statements that you can use in the DATA step.

80 DATA Step Statements by Category 4 Chapter 8 Table 8.1 Executable Statements in the DATA Step Executable Statements ABORT IF, Subsetting PUT Assignment IF-THEN/ELSE PUT, Column CALL INFILE PUT, Formatted CONTINUE INPUT PUT, List DELETE INPUT, Column PUT, Named DESCRIBE INPUT, Formatted PUT, _ODS_ DISPLAY INPUT, List REDIRECT DO INPUT, Named REMOVE DO, Iterative LEAVE REPLACE DO Until LINK RETURN DO While LIST SELECT ERROR LOSTCARD SET EXECUTE MERGE STOP FILE MODIFY Sum FILE, ODS Null UPDATE GO TO OUTPUT Table 8.2 Declarative Statements in the DATA Step Declarative Statements ARRAY DATALINES LABEL Array Reference DATALINES4 Labels, Statement ATTRIB DROP LENGTH BY END RENAME CARDS FORMAT RETAIN CARDS4 INFORMAT WHERE DATA KEEP WINDOW DATA Step Statements by Category In addition to being either executable or declarative, SAS DATA step statements can be grouped into four functional categories:

Statements 4 DATA Step Statements by Category 81 Table 8.3 Categories of DATA Step Statements Statements in this category ACTION CONTROL FILE-HANDLING INFORMATION let you 3 create and modify variables 3 select only certain observations to process in the DATA step 3 look for errors in the input data 3 work with observations as they are being created 3 skip statements for certain observations 3 change the order that statements are executed 3 transfer control from one part of a program to another 3 work with files used as input to the data set 3 work with files to be written by the DATA step 3 give SAS additional information about the program data vector 3 give SAS additional information about the data set or data sets that are being created. The following table lists and briefly describes the DATA step statements by category. Table 8.4 Categories and Descriptions of DATA Step Statements Category Statement Description Action ABORT Stops executing the current DATA step, SAS job, or SAS session Assignment CALL DELETE DESCRIBE ERROR EXECUTE IF, Subsetting LIST LOSTCARD Evaluates an expression and stores the result in a variable Invokes or calls a SAS CALL routine Stops processing the current observation Retrieves source code from a stored compiled DATA step program or a DATA step view Sets _ERROR_ to 1 and, optionally, writes a message to the SAS log Executes a stored compiled DATA step program Continues processing only those observations that meet the condition Writes to the SAS log the input data records for the observation that is being processed Resynchronizes the input data when SAS encounters a missing or invalid record in data that have multiple records per observation

82 DATA Step Statements by Category 4 Chapter 8 Null OUTPUT REDIRECT REMOVE REPLACE STOP Sum WHERE Signals the end of data lines; acts as a placeholder Writes the current observation to a SAS data set Points to different input or output SAS data sets when you execute a stored program Deletes an observation from a SAS data set Replaces an observation in the same location Stops execution of the current DATA step Adds the result of an expression to an accumulator variable Selects observations from SAS data sets that meet a particular condition Control CONTINUE Stops processing the current DO-loop iteration and resumes with the next iteration DO DO, Iterative DO UNTIL DO WHILE END GO TO IF-THEN/ELSE Labels, Statement LEAVE LINK RETURN SELECT Designates a group of statements to be executed as a unit Executes statements between DO and END repetitively based on the value of an index variable Executes statements in a DO loop repetitively until a condition is true Executes statements repetitively while a condition is true Ends a DO group or a SELECT group Moves execution immediately to the statement label that is specified Executes a SAS statement for observations that meet specific conditions Identifies a statement that is referred to by another statement Stops processing the current loop and resumes with the next statement in sequence Jumps to a statement label Stops executing statements at the current point in the DATA step and returns to a predetermined point in the step Executes one of several statements or groups of statements File-handling BY Controls the operation of a SET, MERGE, MODIFY, or UPDATE statement in the DATA step and sets up special grouping variables CARDS CARDS4 Indicates that data lines follow Indicates that data lines that contain semicolons follow

Statements 4 DATA Step Statements by Category 83 DATA DATALINES DATALINES4 FILE FILE, ODS INFILE INPUT INPUT, Formatted INPUT, Column INPUT, List INPUT, Named MERGE MODIFY PUT PUT, Column PUT, Formatted PUT, List PUT, Named Begins a DATA step and provides names for any output SAS data sets Indicates that data lines follow Indicates that data lines that contain semicolons follow Specifies the current output file for PUT statements Defines the structure of the data component that holds the results of the DATA step and binds that component to a template to produce an output object. ODS sends this object to all open ODS destinations, each of which formats the object appropriately. Also controls what happens when the PUT statement tries to write past the end of a line. Identifies an external file to read with an INPUT statement Describes the arrangement of values in the input data record and assigns input values to the corresponding SAS variables Reads input values from specified columns and assigns them to the corresponding SAS variables Reads input values with specified informats and assigns them to the corresponding SAS variables Scans the input data record for input values and assigns them to the corresponding SAS variables Reads data values that appear after a variable name that is followed by an equal sign and assigns them to corresponding SAS variables Joins observations from two or more SAS data sets into single observations Replaces, deletes, and appends observations in an existing SAS data set in place; does not create an additional copy Writes lines to the SAS log, to the SAS procedure output file, or to an external file that is specified in the most recent FILE statement Writes variable values in the specified columns in the output line Writes variable values with the specified format in the output line Writes variable values and the specified character strings in the output line Writes variable values after the variable name and an equal sign

84 Global Statements 4 Chapter 8 PUT, _ODS_ SET UPDATE Writes data values to a special buffer from which they can be written to the data component, and formatted by ODS destinations Reads an observation from one or more SAS data sets Updates a master file by applying transactions Information ARRAY Defines elements of an array Array Reference ATTRIB DROP FORMAT INFORMAT KEEP LABEL LENGTH MISSING RENAME RETAIN Describes the elements in an array to be processed Associates a format, informat, label, and/or length with one or more variables Excludes variables from output SAS data sets Associates formats with variables Associates informats with variables Includes variables in output SAS data sets Assigns descriptive labels to variables Specifies the number of bytes for storing variables Assigns characters in your input data to represent special missing values for numeric data Specifies new names for variables in output SAS data sets Causes a variable that is created by an INPUT or assignment statement to retain its value from one iteration of the DATA step to the next Global Statements Definition Global statements generally provide information to SAS, request information or data, move between different modes of execution, or set values for system options. Other global statements (ODS statements) deliver output in a variety of formats, such as in Hypertext Markup Language (HTML). You can use global statements anywhere in a SAS program. Global statements are not executable; they take effect as soon as SAS compiles program statements. Other SAS software products have additional global statements that are used with those products. For information, see the SAS documentation for those products. Global Statements by Category The following table lists and describes SAS global statements, organized by function into five categories:

Statements 4 Global Statements by Category 85 Table 8.5 Global Statements by Category Statements in this category DATA ACCESS OPERATING ENVIRONMENT LOG CONTROL OUTPUT CONTROL PROGRAM CONTROL WINDOW DISPLAY let you associate reference names with SAS data libraries, SAS catalogs, external files and output devices, and access remote files. access the operating environment directly. alter the appearance of the SAS log. add titles and footnotes to your SAS output; deliver output in a variety of formats. govern the way SAS processes your SAS program. display and customize windows. The following table provides brief descriptions of SAS global statements. For more detailed information, see the individual statements in SAS Language Reference: Dictionary. Table 8.6 Categories and Descriptions of Global Statements Category Statement Description Data Access CATNAME Logically combines two or more catalogs into one by associating them with a catref (a shortcut name); clears one or all catrefs; lists the concatenated catalogs in one concatenation or in all concatenations FILENAME FILENAME, CATALOG Access Method FILENAME, FTP Access Method FILENAME, SOCKET Access Method FILENAME, URL Access Method LIBNAME LIBNAME, SAS/ACCESS Associates a SAS fileref with an external file or an output device; disassociates a fileref and external file; lists attributes of external files References a SAS catalog as an external file Allows you to access remote files using the FTP protocol Allows you to read from or write to a TCP/IP socket Allows you to access remote files using the URL access method Associates or disassociates a SAS data library with a libref (a shortcut name); clears one or all librefs; lists the characteristics of a SAS data library; concatenates SAS data libraries; implicitly concatenates SAS catalogs. Associates a SAS libref with a database management system (DBMS) database, schema, server, or group of tables or views Log Control Comment Documents the purpose of the statement or program PAGE SKIP Skips to a new page in the SAS log Creates a blank line in the SAS log

86 Global Statements by Category 4 Chapter 8 Operating Environment X Issues an operating-environment command from within a SAS session Output Control FOOTNOTE Prints up to ten lines of text at the bottom of the procedure or DATA step output ODS EXCLUDE ODS HTML ODS LISTING ODS OUTPUT ODS PATH ODS PRINTER ODS SELECT ODS SHOW ODS TRACE ODS VERIFY TITLE Specifies output objects to exclude from ODS destinations Opens, manages, or closes the HTML destination. If the destination is open, you can create HTML output (output that is written in Hypertext Markup Language). Opens, manages, or closes the Listing destination Creates a SAS data set from an output object and manages the selection and exclusion lists for the Output destination Specifies which locations to search for definitions that were created by PROC EMPLATE, as well as the order in which to search for them Opens, manages, or closes the Printer destination. If the destination is open, you can create Printer output (output that is formatted for a high-resolution printer) Specifies output objects for ODS destinations Writes to the SAS log the specified selection or exclusion list Writes to the SAS log a record of each output object that is created, or suppresses the writing of this record Prints or suppresses a warning that a style definition or a table definition that is used is not supplied by SAS Institute Specifies title lines for SAS output Program Control DM Submits SAS Program Editor, Log, Procedure Output or text editor commands as SAS statements ENDSAS %INCLUDE %LIST OPTIONS RUN Terminates a SAS job or session after the current DATA or PROC step executes Brings a SAS programming statement, data lines, or both, into a current SAS program Displays lines that are entered in the current session Changes the value of one or more SAS system options Executes the previously entered SAS statements %RUN Ends source statements following a %INCLUDE * statement Window Display DISPLAY Displays a window that is created with the WINDOW statement WINDOW Creates customized windows for your applications

The correct bibliographic citation for this manual is as follows: SAS Institute Inc., SAS Language Reference: Concepts, Cary, NC: SAS Institute Inc., 1999. 554 pages. SAS Language Reference: Concepts Copyright 1999 SAS Institute Inc., Cary, NC, USA. ISBN 1 58025 441 1 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, by 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, November 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, ACF/VTAM, AIX, APPN, MVS/ESA, OS/2, OS/390, VM/ESA, and VTAM are registered trademarks or trademarks of International Business Machines 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.