Syntax Conventions for SAS Programming Languages

Similar documents
Getting Started with the SAS 9.4 Output Delivery System

Getting Started with the SAS 9.4 Output Delivery System

Encryption in SAS 9.3 Second Edition

SAS 9.3 System Options

Using a Picture Format to Create Visit Windows

Storing and Reusing Macros

DBLOAD Procedure Reference

Using the SQL Editor. Overview CHAPTER 11

Creating and Executing Stored Compiled DATA Step Programs

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

Journey to the center of the earth Deep understanding of SAS language processing mechanism Di Chen, SAS Beijing R&D, Beijing, China

The GREMOVE Procedure

CHAPTER 1 Introduction to SAS/GRAPH Software

SAS Model Manager 2.2. Tutorials

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

The GANNO Procedure. Overview CHAPTER 12

April 4, SAS General Introduction

Statements. Previous Page Next Page. SAS 9.2 Language Reference: Dictionary, Third Edition. Definition of Statements. DATA Step Statements

QUEST Procedure Reference

SAS 101. Based on Learning SAS by Example: A Programmer s Guide Chapter 21, 22, & 23. By Tasha Chapman, Oregon Health Authority

The GIMPORT Procedure

SAS Model Manager 2.3

External Files. Definition CHAPTER 38

Exporting Variable Labels as Column Headers in Excel using SAS Chaitanya Chowdagam, MaxisIT Inc., Metuchen, NJ

SAS PROGRAMMING AND APPLICATIONS (STAT 5110/6110): FALL 2015 Module 2

Exploring DICTIONARY Tables and SASHELP Views

Procedures. PROC CATALOG CATALOG=<libref.>catalog <ENTRYTYPE=etype> <KILL>; CONTENTS <OUT=SAS-data-set> <FILE=fileref;>

Simplifying Your %DO Loop with CALL EXECUTE Arthur Li, City of Hope National Medical Center, Duarte, CA

Tales from the Help Desk 5: Yet More Solutions for Common SAS Mistakes Bruce Gilsen, Federal Reserve Board

SAS 9.2 Table Server. TSPL Language Reference

Batch Importing. Overview CHAPTER 4

SAS Viya 3.1 FAQ for Processing UTF-8 Data

The SERVER Procedure. Introduction. Syntax CHAPTER 8

Using Unnamed and Named Pipes

Customizing Your SAS Session

Creation of SAS Dataset

ABSTRACT MORE THAN SYNTAX ORGANIZE YOUR WORK THE SAS ENTERPRISE GUIDE PROJECT. Paper 50-30

Using SAS Files. Introduction CHAPTER 5

SAS Programming Basics

Doing More with SAS/ASSIST 9.1

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.

SAS Data Libraries. Definition CHAPTER 26

Going Under the Hood: How Does the Macro Processor Really Work?

CHAPTER 7 Using Other SAS Software Products

HOW TO DEVELOP A SAS/AF APPLICATION

CHAPTER 13 Importing and Exporting External Data

SAS. Studio 4.1: User s Guide. SAS Documentation

Configuring SAS Web Report Studio Releases 4.2 and 4.3 and the SAS Scalable Performance Data Server

Surviving the SAS Macro Jungle by Using Your Own Programming Toolkit Kevin Russell, SAS Institute Inc., Cary, North Carolina

ET01. LIBNAME libref <engine-name> <physical-file-name> <libname-options>; <SAS Code> LIBNAME libref CLEAR;

SPEECH RECOGNITION COMMON COMMANDS

The GEOCODE Procedure and SAS Visual Analytics

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

MARK CARPENTER, Ph.D.

The GSLIDE Procedure. Overview. About Text Slides CHAPTER 27

An Introduction to SAS/FSP Software Terry Fain, RAND, Santa Monica, California Cyndie Gareleck, RAND, Santa Monica, California

The DATA Statement: Efficiency Techniques

Using PROC REPORT to Cross-Tabulate Multiple Response Items Patrick Thornton, SRI International, Menlo Park, CA

SAS Drug Development Program Portability

Basic Concept Review

SAS 9.4 Intelligence Platform: Migration Guide, Second Edition

Moving and Accessing SAS 9.2 Files

Moving and Accessing SAS. 9.1 Files

Chapter 7 File Access. Chapter Table of Contents

DATA Step Debugger APPENDIX 3

Uncommon Techniques for Common Variables

Procedure for Stamping Source File Information on SAS Output Elizabeth Molloy & Breda O'Connor, ICON Clinical Research

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

SAS/FSP 9.2. Procedures Guide

Using an ICPSR set-up file to create a SAS dataset

The Basics of PROC FCMP. Dachao Liu Northwestern Universtiy Chicago

SAS Drug Development. SAS Macro API 1.3 User s Guide

jbase Background Processing

Procedures. Calls any BMDP program to analyze data in a SAS data set

Because We Can: Using SAS System Tools to Help Our Less Fortunate Brethren John Cohen, Advanced Data Concepts, LLC, Newark, DE

SAS 9.3 LIBNAME Engine for DataFlux Federation Server

SAS Business Rules Manager 1.2

Essential ODS Techniques for Creating Reports in PDF Patrick Thornton, SRI International, Menlo Park, CA

Paper HOW-06. Tricia Aanderud, And Data Inc, Raleigh, NC

Introduction. Getting Started with the Macro Facility CHAPTER 1

Cisco Conventions Used in Cisco Technical Tips

Using Maps with the JSON LIBNAME Engine in SAS Andrew Gannon, The Financial Risk Group, Cary NC

Performance Considerations

Changes and Enhancements

SAS Drug Development 3.5

SAS Studio 4.3: User s Guide

The FORMAT procedure - more than just a VALUE statement Lawrence Heaton-Wright, Quintiles, Bracknell, UK

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

INTRODUCTION TO SAS HOW SAS WORKS READING RAW DATA INTO SAS

CROSSREF Manual. Tools and Utilities Library

Utilizing the VNAME SAS function in restructuring data files

Locking SAS Data Objects

APPENDIX 2 Customizing SAS/ASSIST Software

Formal Figure Formatting Checklist

The GTESTIT Procedure

Accessing Data and Creating Data Structures. SAS Global Certification Webinar Series

The FORMS Procedure. Overview CHAPTER 20

SAS File Management. Improving Performance CHAPTER 37

SAS Information Map Studio 2.1: Tips and Techniques

How to Create Data-Driven Lists

Transcription:

Syntax Conventions for SAS Programming Languages SAS Syntax Components Keywords A keyword is one or more literal name components of a language element. Keywords are uppercase, and in reference documentation, they are bold. In other documents, such as user guides, keywords are uppercase only. Single Keywords CHAR (string, position) ALTER (alter-password) BEST w. REMOVE <data-set-name> Multiple Keywords in CALL Routines CALL routines have two keywords, CALL and the routine name: CALL RANBIN (seed, n, p, x) Keywords with No Arguments DO;... SAS code... END;

2 Multiple Keywords in Procedure Statements Some procedure statements have multiple keywords throughout the statement syntax: CREATE <UNIQUE> INDEX index-name ON table-name (column-1 <, column-2, >) Choice between Multiple Keywords Some system options require that you choose between one of two keywords: DUPLEX NODUPLEX Arguments An argument follows a keyword or is on the right side of an assignment statement. Arguments specify a numeric or character constant, variable, or expression that is used by SAS to process the language element. In most cases, arguments appear in italic. Arguments can be required or optional. In syntax, optional arguments are enclosed in angle brackets (< >). Required Arguments Required arguments are not enclosed in angle brackets (< >). CHAR (string, position) In this example, the CHAR function has two required arguments, string and position. In this code example, the value 'summer' is the string argument and the value 4 is the position argument: x=char('summer', 4); Optional Arguments Optional arguments are enclosed in angle brackets (< >). COMPRESS (source <, characters> <, modifier(s)>); In this example, source is a required argument, whereas characters and modifier(s) are optional arguments. In this code example, the argument string is the source, "12345" are the characters, and "d" is the modifier: compress(string, "12345", "d"); Argument Lists In syntax, argument(s) specifies that one argument is required and that multiple arguments are allowed. Use a space to separate arguments. Punctuation, such as a comma (, ) is not required between arguments. The MISSING statement is an example. MISSING character(s); data survey; missing a r; input id answer; datalines; 001 2 002 R 003 1 004 A

3 005 2 ; Another type of argument list is argument-1 <, argument-2,...>. For example: AUTHPROVIDERDOMAIN (provider-1:domain-1 <, provider-2:domain-2, > INTO :macro-variable-specification-1 <, :macro-variable-specification-2, > Keyword-Argument Pairs An argument pair associates a keyword with an argument. You can specify multiple keyword-argument pairs. No punctuation is required between keyword-argument pairs. The ellipsis (...) indicates that additional keywordargument pairs are allowed. For example: BY <DESCENDING> variable-1 <<DESCENDING> variable-2 >; In this syntax example, DESCENDING is the keyword and variable-x is the argument. The BY statement can be specified in several procedures. In this SORT procedure, the data set status.qtr4 is sorted in descending order by the value of the variable Week: proc sort data=status.qtr4; by descending week; run; Argument-Option Pairs You can associate some arguments with options. No punctuation is required between the argument and the option. The ellipsis (...) indicates that additional arguments with an associated option are allowed: argument-1 <option(s)> <argument-2 <option(s)>...> The FORMAT procedure PICTURE statement is an example of an argument-option pair. For each value-rangeset that you specify, you can provide picture-option(s): PICTURE name <(format-option(s))> <value-range-set-1 <(picture-1-option(s))> <value-range-set-2 <(picture-2-option(s))> >>; In this code example, the first value-range-set 1E06 1000000000='0000 M' has two options, prefix='$' and mult=.000001: proc format; picture bigmoney (fuzz=0) 1E06-<1000000000='0000 M' (prefix='$' mult=.000001) 1E09-<1000000000000='0000 B' (prefix='$' mult=1e-09) 1E12-<1000000000000000='0000 T' (prefix='$' mult=1e-012); Argument Assignments Some syntax allows one or more arguments to be assigned a value. No punctuation is required between arguments. The ellipsis (...) indicates that additional arguments are allowed: argument-1=value-1 <argument-2=value-2...> The LABEL statement is an example of multiple arguments: LABEL variable-1=label-1 <variable-2=label-2 >; label score1="grade on April 1 Test" score2="grade on May 1 Test";

4 Styles and Special Characters Style The style conventions that are used in documenting SAS syntax include uppercase bold, uppercase, and italic. UPPERCASE BOLD identifies SAS keywords such as the names of functions or statements. In this example, the keyword ERROR is written in uppercase bold: ERROR <message>; UPPERCASE identifies arguments that are literals. In this example of the CMPMODEL= system option, the literals are BOTH, CATALOG, and XML: CMPMODEL=BOTH CATALOG XML italic identifies arguments or values that you supply. Items in italic represent user-supplied values that are either nonliteral arguments or nonliteral values: nonliteral arguments. In this example of the LINK statement, the argument label is a user-supplied value and therefore appears in italic: LINK label; nonliteral values that are assigned to an argument. In this example of the FORMAT statement, the argument DEFAULT is assigned the variable default-format: FORMAT variable(s) <format > <DEFAULT = default-format>; Special Characters The syntax of SAS language elements can contain these special characters: = An equal sign identifies a value for a literal in some language elements such as system options. In this example of the MAPS system option, the equal sign sets the value of MAPS: MAPS=location-of-maps < > Angle brackets identify optional arguments. A required argument is not enclosed in angle brackets. In this example of the CAT function, at least one item is required: CAT (item-1 <, item-2, >) A vertical bar indicates that you can choose one value from a group of values. Values that are separated by the vertical bar are mutually exclusive. In this example of the CMPMODEL= system option, you can choose only one of the literal arguments: CMPMODEL=BOTH CATALOG XML

... An ellipsis indicates that an argument can be repeated. If the argument and the ellipsis are enclosed in angle brackets, then the argument is optional. The repeated argument must contain punctuation if it appears before or after the initial argument. In this example of the CAT function, multiple item arguments are allowed, and they must be separated by a comma: CAT (item-1 <, item-2, >) 'value' or "value" Single or double quotation marks that enclose an argument indicate that the argument must have a value that is also enclosed in single or double quotation marks. ; In this example of the FOOTNOTE statement, the argument text is enclosed in quotation marks: FOOTNOTE <n> <ods-format-options 'text' "text">; A semicolon indicates the end of a statement or CALL routine. In this example, each statement ends with a semicolon: data namegame; length color name $8; color = 'black'; name = 'jack'; game = trim(color) name; run; 5 References to SAS Libraries and External Files Many SAS statements and other language elements refer to SAS libraries and external files. You can make the reference through a logical name (a libref or fileref), or you can use the physical filename enclosed in quotation marks. If you use a logical name to make the reference, you typically use a SAS statement (LIBNAME or FILENAME) or the operating environment's control language. Several methods of referring to SAS libraries and external files are available, and some of these methods depend on your operating environment. In the examples that use SAS libraries, SAS documentation uses the italicized phrase SAS-library enclosed in quotation marks. In the examples that use external files, SAS documentation uses the italicized phrase filespecification: infile file-specification obs = 100; libname libref 'SAS-library'; 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. Other brand and product names are trademarks of their respective companies. Copyright 2016, SAS Institute Inc., Cary, NC, USA. All Rights Reserved. May 2016 1.0-P1:lesyntaxconv

6