A Guided Tour Through the SAS Windowing Environment Casey Cantrell, Clarion Consulting, Los Angeles, CA

Similar documents
2 The Stata user interface

SAS Studio: A New Way to Program in SAS

Beginning Tutorials. PROC FSEDIT NEW=newfilename LIKE=oldfilename; Fig. 4 - Specifying a WHERE Clause in FSEDIT. Data Editing

Altering Layouts. Changing Font. Universal Engraving Machine. Chapter 18 Altering Layouts

Guide to User Interface 4.3

Sage Getting Started Guide. September 2017

WPS Workbench. user guide. "To help guide you through using the WPS user interface (Workbench) to create, edit and run programs"

Spreadsheet definition: Starting a New Excel Worksheet: Navigating Through an Excel Worksheet

SAS Universal Viewer 1.3

Introduction to Microsoft Excel 2010

Dynamic Projects in SAS Enterprise Guide How to Create and Use Parameters

Windows Computer A to Z Shortcut Key list with PDF

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

SAS/ASSIST Software Setup

Oracle General Navigation Overview

Introduction. CHAPTER 3 Working in the SAS Windowing Environment

Creating a data file and entering data

Chapter 2. Basic Operations. you through the routine procedures that you will use nearly every time you work with SPSS.

Chapter 2 The SAS Environment

2010/04/19 11:38. Describing a unique product that shows the mainframe in a completely different way.

Address Bar. Application. The space provided on a web browser that shows the addresses of websites.

Demonstration Script: Uniplex Business Software Version 8.1 Upgrading to Version 8.1

Microsoft Word 2010 Introduction to Mail Merge

A Practical Introduction to SAS Data Integration Studio

Embarcadero PowerSQL 1.1 Evaluation Guide. Published: July 14, 2008

Getting Up to Speed with PROC REPORT Kimberly LeBouton, K.J.L. Computing, Rossmoor, CA

ClickFORMS Quickstart Tutorial

Sage Getting Started Guide

Remodeling Your Office A New Look for the SAS Add-In for Microsoft Office

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

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

The first time you open Word

Introduction to Personal Computing

Introduction to Microsoft Excel 2010

Word - Basics. Course Description. Getting Started. Objectives. Editing a Document. Proofing a Document. Formatting Characters. Formatting Paragraphs

SAS/Warehouse Administrator Usage and Enhancements Terry Lewis, SAS Institute Inc., Cary, NC

STAT 7000: Experimental Statistics I

Veco User Guides. Grids, Views, and Grid Reports

Basic E-Sticker Pack User Guide

QuickStart Guide MindManager 7 MAC

Abacus 32 Windows Menu System

Interface. 2. Interface Adobe InDesign CS2 H O T

STAT 3304/5304 Introduction to Statistical Computing. Introduction to SAS

Introduction to Excel

SAS Business Rules Manager 1.2

PEACHTREE COMPLETE 2008 AN INTRODUCTION TO PEACHTREE COMPLETE ACCOUNTING

Submitting Code in the Background Using SAS Studio

Introduction to Microsoft FrontPage

Photoshop tutorial: Final Product in Photoshop:

version 7.6 user manual

-Using Excel- *The columns are marked by letters, the rows by numbers. For example, A1 designates row A, column 1.

Fusion. CBR Fusion MLS Level 1 Core Functions. Class Handout

SAS. Studio 4.1: User s Guide. SAS Documentation

Getting Started with Solar Eclipse. Release 8.6.5

Expedient User Manual Getting Started

BASIC NAVIGATION & VIEWS...

Using SAS Files. Introduction CHAPTER 5

COMPUTER FOR BEGINNERS

You can record macros to automate tedious

Basic Microsoft Word

Scribe 4 Manual 2. Scribe 4

Maximizing the Power of Excel With Macros and Modules

Colleague by Ellucian Guide to User Interface 4.4 and 4.4.1

Enterprise Client Software for the Windows Platform

Microsoft Word Introduction

The Fundamentals. Document Basics

LESSON ONE AND TWO TOPIC: HOW TO USE MICROSOFT WORD. : Putu Putra Astawa, S.Kom.,M.Kom

Attachmate EXTRA! X-treme Evaluator s Guide

Microsoft FrontPage Practical Session

Edit the Editor: Creating Keyboard Macros in SAS Enterprise Guide

TABLE OF CONTENTS CHAPTER

SlickEdit Gadgets. SlickEdit Gadgets

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

Display Systems International Software Demo Instructions

EXCEL BASICS: MICROSOFT OFFICE 2007

Learning Guide for User Interface 4.3

Embarcadero DB Optimizer 1.0 Evaluation Guide. Published: July 14, 2008

Read Now In-Browser Reader Guide

Human Resource Management System User Guide

DEPARTMENT OF HEALTH AND HUMAN SCIENCES HS900 RESEARCH METHODS

Using Reports. Access 2013 Unit D. Property of Cengage Learning. Unit Objectives. Files You Will Need

Perforce Getting Started with P4V

Table of Contents. Page 2 of 72. High Impact 4.0 User Manual

Microsoft Word: Steps To Success (The Bare Essentials)

Instructions for Using the Databases

New Finance Officer & Staff Training

Vision Pointer Tools

Introduction to the SAS System

Basic Concepts. Launching MultiAd Creator. To Create an Alias. file://c:\documents and Settings\Gary Horrie\Local Settings\Temp\~hh81F9.

Increased Productivity Through The Use Of The Display Manager System Jim Anderson, Blue Cross Blue Shield of Nebraska

Site Owners: Cascade Basics. May 2017

TI-SmartView Emulator Software for the TI-84 Plus Family (Windows and Macintosh )

Introduction to CS Dealing with tables in Word Jacek Wiślicki, Laurent Babout,

SAS Data Libraries. Definition CHAPTER 26

Objective 1: Familiarize yourself with basic database terms and definitions. Objective 2: Familiarize yourself with the Access environment.

StarTeam File Compare/Merge StarTeam File Compare/Merge Help

USER MANUAL. Version May 2015

Intro to Microsoft Word

Easy Windows Working with Disks, Folders, - and Files

INTViewer Tutorial Cube Tutorial

Transcription:

A Guided Tour Through the SAS Windowing Environment Casey Cantrell, Clarion Consulting, Los Angeles, CA ABSTRACT The SAS system running in the Microsoft Windows environment contains a multitude of tools that can make the process of learning, and using SAS much easier. The interface simplifies communication with the operating system and provides us immediate and familiar access to our data. The programmer may perform common data management tasks with the click of a mouse, customize the working environment and use a variety of tools common to other Windows applications. This workshop will provide an orientation to the SAS windowing environment, and will demonstrate how to edit and submit programs, manage output, and build and save SAS system files. INTRODUCTION The first versions of SAS, written primarily in FORTAN and Pl/I, were developed to run on IBM mainframe computers. In the mid 1980 s SAS was rewritten in C, a more flexible and durable language. This was an important change, making SAS what it is today: a highly portable, platform independent information delivery system. SAS not only has the capacity to work with foreign file types, such as SPSS or dbase, but SAS programs themselves may be run on a variety of computing platforms. One may combine data in ORACLE from a mainframe with a db2 file from a PC, generate forecasting information using SAS ETS and write out the results into an Excel file. RUNNING SAS PROGRAMS Regardless of platform, there are at least two and typically three steps involved with running SAS programs: Write the program Submit the program for execution View results When run, a SAS program will generate a log, which contains messages from the system about the execution of the program, and an output listing, which contains results of the program, such as tables or statistics if any are produced. SAS programs may be executed in batch mode or within the SAS interactive windowing environment. When running jobs in batch, the programmer writes the program, then submits the program file to the system for execution. System resources are typically shared with other users. Programs, program logs and any results are saved on the system as separate files. When working interactively, the programmer initiates and works within a SAS session, so all activity takes place in SAS. One may write a program in the SAS program editor or open into the editor a program saved as a file. The program log and any output appear in separate windows. The contents of windows are temporary unless specifically saved to a file outside the session. SAS DISPLAY MANAGER Although this workshop will discuss elements that are common to all SAS programs regardless of operating system, we will pay particular attention to features found in the SAS Display Manager running on Microsoft Windows. 1

SAS WINDOWS Although you can customize the SAS windowing environment, when you first initiate a session, your screen will usually look something like the one shown in Figure 1. COMMAND BAR DROP-DOWN MENUS TOOLBAR ACTIVE WINDOW CURSOR POSITION Figure 1 SAS Windows Environment Active window Although you may open multiple windows, only one will be active at any one time. Commands and actions will work only for the active window, which is typically highlighted in blue on your screen. Drop-down menus Drop-down menus for the active window will appear across the top of your screen. Menus and menu items will change depending on which window is active. Toolbar The toolbar provides icons for actions you perform most often. In addition, you can change the tool icons and/or create your own tools. Cursor position This indicates the position of the cursor in the program editor window. Command bar You may type commands into the command box as an alternative to using menus. The command bar keeps a list of commands previously entered, so you can quickly repeat a command. 2

Figure 2 Recalling previous commands Although three windows appear when you first start your SAS session, five are available. They are: Program editor This is where you will write, edit and submit your programs. Log SAS system message will appear in this window when your program is executed. Output window Listings generated by your program will appear here. Explorer window You may perform various file management tasks, such as opening, moving, and copying files, from this window. Results window This window provides an outline of SAS output generated during the session, making it easy to view, print and save specific tables or listings. WINDOWS Figure 3 Available windows WORKING WITH THE SAS WINDOWS The Display Manager supports many of the tools common to other Windows applications that allow you modify the layout on your screen. You may open, close, minimize and maximize windows and/or resize and move them to suit your individual preferences. 3

MAXIMIZE MINIMIZE CLOSE Figure 4 Tools to resize windows You may open or reopen any window from the VIEW drop-down menu. Figure 5 Using the view menu There are various ways to navigate across windows as well. Clicking anywhere within a window will activate that window. Or you may use the WINDOW drop-down menu (see Figure 3) or the task bars located at the bottom of your screen. TASK BARS Figure 6 Task bars THE SAS PROGRAM EDITOR The enhanced program editor provides myriad tools to make your job easier. You may expand and collapse individual sections in your program, define your own function keys and record macros to automate redundant editing. The color-coding feature, which allows you to define colors specific to program components, helps locate syntax errors. 4

In addition to making your programs easier to read, collapsing sections also makes it easy to differentiate steps, since all statements in the step, except for those on the first line, will collapse when this features is used. Remember that steps are processed separately in SAS. You may not mix PROC steps with DATA steps. COLLAPSED NOT COLLAPSED Figure 7 Collapsing program steps Although SAS provides a set of pre-defined function keys, these, too are completely customizable. To open the DMKEYS window, type KEYS into the command box. You may type a command into the definition of any unused key or change the definition of an existing function key. If you wish, you can combine commands by separating them with a semicolon. KEY PERFORMS TWO ACTIONS Figure 8 Customizing function keys Similarly, the keyboard macro tool can be used to automate repetitive editing tasks. The macro can store commands or even keystrokes. In the examples shown in Figure 9, the $ character needs to be added to each format name. 5

ADD $ Figure 9 Using the Macro recorder To do this by hand, one needs to position the cursor at the beginning of the format name, e.g., NEEDLANG, type $, then move the cursor to the next line and repeat the process. To do this with one key stroke, let s create a keyboard macro. First, select Keyboard Macros from the TOOLS menu. Then select Record New Macro. An image of a cassette tape will appear in the window as will the message ( Recording ) as shown in Figure 11. Figure 10 Invoking the Macro recorder Since the cursor is already positioned at the beginning of each format name, we now need only to enter the necessary keystrokes to change a single format,. We ll type $, press the down arrow key to move the cursor to the next line, then press the left arrow key to move the cursor back one space. Figure 11 Macro recorder in record mode 6

To stop recording, return to the Keyboard Macros menu, and select Stop Recording. Figure 12 Stopping the Macro recorder We can now save the macro and give it a name or assign a function key to use it. Figure 13 Saving a keyboard macro USING THE SAS EDITOR TO WRITE PROGRAMS You may edit your SAS program using any text editor and then import it into your SAS session, but most SAS Windows programmers find it easier to write programs in the Program Editor itself. The cut and paste features familiar to Windows users work in the SAS editor and many common editing actions are available from the EDIT drop-down menu as well. To begin working in the program editor, click anywhere in the window titled Editor. Alternately you may type Prog in the command line or access the window through a menu. Remember, although you may have several windows open, you may only work in one window at a time. The name of the active window will be highlighted in blue. Figure 14 shows a simple program that creates a temporary SAS file named pups. The file will contain 5 records or observations and 4 variables: name, sex, weight1 and weight6. As indicated by the $, name and sex will be character variables. 7

Figure 14 Simple SAS program Again, there are various ways to execute your program. You may select SUBMIT from the Run menu, type Submit in the command window or press the Submit icon in the toolbar. Figure 15 Using the Run menu SUBMIT COMMAND SUBMIT ICON Figure 16 Issuing the SUBMIT command or using the SUBMIT icon 8

THE PROGRAM LOG WINDOW All too often, programmers look for output, assuming that their program ran successfully if listings were generated. This will inevitably get you into trouble, so make it a habit to review the program log first. In this example, there were no syntax errors, but let s look more closely at the information the log provides. Does the output file contain the number of records and number or variables we expect? INFORMATION ABOUT DATA SET Figure 17 The SAS program log The program shown in Figure 18 failed because of a spelling error. Figure 18 Spelling error as shown in the program log To correct the mistake, we will bring the program back into the Program Editor by typing recall into the command box, or by using the Recall last submit item under the RUN menu. Figure 19 Recalling the last program executed 9

ERROR CORRECTION Figure 20 Correcting the error THE OUTPUT AND RESULTS WINDOWS Now that we have built a SAS system file, we can use any of the numerous procedures available in SAS to get information from it. Most, but not all PROCs generate output that we can view in the Output window. Let s run a PROC PRINT to get a listing of the file. When we submit the program, the Output window will automatically become the active window and will appear in the foreground on our screen. Note that the Results window now contains an object labeled Print: The SAS System. Although we can scroll through the output in the Output window, this can become quite tedious once we ve run multiple programs, since the listings will remain there until we clear the contents. The Results window provides an outline of the output generated during our session, making it easy to find a particular item. PRINT OUTPUT Figure 21 Output listed in the Results window Let s run another procedure to see how this works. The program shown in Figure 22 generates frequencies for the variables in our file. Since there are only four variables, we can see them all quite easily. If however, we had hundreds of lines of output and wanted to locate a particular table, we could do this quickly using the Results window. Figure 22 - PROC FREQ 10

FREQUENCY TABLES Figure 23 Output generated from PROC FREQ Clicking on the item labeled Freq: The SAS System displays a list of every table generated by that PROC. Clicking on any item in the list will take us to that specific table in the Output window. Figure 24 Output generated from PROC FREQ To clear the contents of any window, select Clear all from the Edit drop-down menu, or type clear into the command box. Make certain the window you wish to clear is the active window by clicking anywhere in that window. Remember the active window will move to the front of the screen and its name bar will be highlighted. Figure 25 Clearing contents of Output window from EDIT menu 11

COMMAND BOX Figure 26 Clearings contents of Output window from command line SAS SYSTEM FILE NAMES All SAS data files have two part names. The first part refers to the LIBRARY, or folder where the physical file is, or will be, stored. The second part is the FILENAME, which identifies the data set in the folder. When used in a program, the two parts are separated by a dot, i.e. LIBRARY.FILENAME. SAS system files may be temporary, meaning they exist only for the duration of the program or session, or they may be stored as permanent files, which may be used later. Temporary files are stored in a library called WORK that SAS defines automatically when the session is started. When our sample program ran successfully, the SAS log contained the following NOTE: The data set WORK.PUPS has 5 observations and 4 variables. NOTE Figure 27 Temporary SAS file written to WORK directory : 12

Since we did not use a two part name in our program, SAS wrote the file to the default WORK library. Consequently, our file will be erased when we terminate our SAS session. THE EXPLORER WINDOW The Explorer window provides various tools for working with SAS data sets. Although it is particularly useful for managing multiple files, we ll use it now to look at the data set created above. First click on the Libraries icon in the Explorer window. This will open a window showing the libraries currently available to us. Since our file was written to the Work library, click on that icon to see the contents of the library. WORK LIBRARY Figure 28 Active libraries displayed in the Explorer window The icon displayed indicates the file is a SAS system file. SAS FILE Figure 29 Contents of WORK library Click on the Pups icon to open the file. Note that the menu bar now has a different set of icons available. We are currently in Table View mode, which enables us to see the entire data set. 13

SORT TABLE VIEW COLUMN ATTRIBUTES BROWSE MODE FORM VIEW TABLE ATTRIBUTES EDIT MODE Figure 30 VIEWTABLE Let s explore further. Figure 31 shows options available in the View menu that control how the file is displayed. Figure 31 Options available from the View menu Clicking the Column Attributes icon displays information about each variable in the file, as shown in Figure 32.. Figure 32 Column Attributes window 14

We can add labels, formats and informats from this screen. Figure 33 Adding a format from the Column Attributes window We can also change label fonts or colors if we wish. Figure 34 Changing font and color from the Column Attributes window Clicking the Table Attributes button displays information about the entire file. Figure 35 Table Attributes window 15

Form View displays records one at a time. Figure 36 Form View window The Edit and Browse buttons control access to the file. The default mode is Browse. You must toggle the Edit mode icon to sort or make changes to the data. Figure 37 Edit mode Several editing actions are available from the Edit pull down menu. Figure 38 File menu Edit options To sort the file, select the appropriate sort order key to reach the Sort screen where you then the select sort order variables. DESCENDING ASCENDING Figure 39 Selecting sort order 16

To select variables you want to sort by, highlight the variable name in the Available box, then press the right arrow key to move it into the Selected box. To remove the variable from the Selected list, press the left arrow key. SELECT Figure 40 Selecting sort order variables SAS LIBRARIES SAS system files may be temporary or they may be stored as permanent files. Temporary files exist only for the duration of the program or session, while permanent files may be used later. To create a permanent file, you need to define a SAS library, which tells SAS where you want to store your SAS files. To define your library interactively, click on the New Library icon in the toolbar or right click on the Libraries icon in the Explorer window. LIBRARIES ICON NEW LIBRARY ICON Figure 41 Defining SAS libraries Right click the Libraries icon, then select New. Figure 42 Using the Libraries icon to define a SAS library 17

Either method will bring up the dialogue box pictured in Figure 43. Type the desired library name into the Name box. Library names cannot exceed 8 characters, must begin with a letter or underscore and may include only letters, numbers or underscores. Figure 43 New library dialogue box You may type in the path information, or click the Browse key shown in Figure 43 to locate the appropriate folder interactively as shown in Figure 44 Figure 44 Using the Browse option to define a SAS library folder If you want the library defined each time you start a SAS session, check the Enable at startup box. Figure 45 Automatically defining a SAS library at startup 18

CONCLUSION In this workshop, we have demonstrated the use of several tools available in the SAS Display Manager. SAS has integrated features common to other Windows applications into an environment that provides a sophisticated and intuitive editor, quick and easy data management tools and a logical system for organizing output. The programmer who understands and uses these tools will certainly experience increased productivity. REFERENCES SAS Institute (1999) SAS Companion for the Microsoft Windows Environment, Version 8, Cary, NC: SAS Institute Inc. TRADEMARK 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. AUTHOR CONTACT Casey Cantrell Clarion Consulting 4404 Grand View Blvd. Los Angeles, CA 90066 caseycantrell@comcast.net 19