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



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

Introduction to SAS on Windows

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

Getting Started With SPSS

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

UOFL SHAREPOINT ADMINISTRATORS GUIDE

4 Other useful features on the course web page. 5 Accessing SAS

darlingharbour.com Content Management System Tenant User Guide

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

UHR Training Services Student Manual

Lesson 07: MS ACCESS - Handout. Introduction to database (30 mins)

Topography of an Origin Project and Workspace

The. Little SAS Book

IBM Rational Developer for i. Maintain an ILE RPG application using Remote System Explorer Edit, Compile, and Debug

App Building Guidelines

An Introduction to SAS/SHARE, By Example

Umbraco v4 Editors Manual

How to Download Census Data from American Factfinder and Display it in ArcMap

Introduction to IBM SPSS Statistics

SAS PROGRAMMING ESSENTIALS FOR STATISTICAL COMPUTING IN DAIRY RESEARCH

MAS 500 Intelligence Tips and Tricks Booklet Vol. 1

Chapter 2 The Data Table. Chapter Table of Contents

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

USER GUIDE. Let s get started! Notepad Basics Notepad Settings Keyboard Editor Getting Organized Sharing your work...

Introduction to SPSS 16.0

SPSS: Getting Started. For Windows

Microsoft Office Access 2007 Basics

Top 10 Things to Know about WRDS

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

Fairfield University Using Xythos for File Sharing

Introduction to Microsoft Access XP

Excel 2003 Tutorial I

File Management With Windows Explorer

Using Adobe Dreamweaver CS4 (10.0)

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

CHAPTER 6: SEARCHING AN ONLINE DATABASE

Mentor Tools tutorial Bold Browser Design Manager Design Architect Library Components Quicksim Creating and Compiling the VHDL Model.

Introduction To Microsoft Office PowerPoint Bob Booth July 2008 AP-PPT5

3 IDE (Integrated Development Environment)

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

GOOGLE DOCS APPLICATION WORK WITH GOOGLE DOCUMENTS

Simply Accounting Intelligence Tips and Tricks Booklet Vol. 1

How to create pop-up menus

How to Edit Your Website

Business Portal for Microsoft Dynamics GP User s Guide Release 5.1

NDSU Technology Learning & Media Center. Introduction to Google Sites

For Introduction to Java Programming, 5E By Y. Daniel Liang

Business Objects Enterprise version 4.1. Report Viewing

WebEx Remote Access User s Guide

Professional. SlickEdif. John Hurst IC..T...L. i 1 8 О 7» \ WILEY \ Wiley Publishing, Inc.

X-Trade Brokers Dom Maklerski S.A. XTB Expert Builder. Tutorial. Michał Zabielski

ITP 101 Project 3 - Dreamweaver

MICROSOFT ACCESS 2003 TUTORIAL

SAS IT Resource Management 3.2

Paper FF-014. Tips for Moving to SAS Enterprise Guide on Unix Patricia Hettinger, Consultant, Oak Brook, IL

Getting Started with Access 2007

Word 2007: Basics Learning Guide

MEDILINK ESI (R2) How To: Use the Medilink Document Management System. Casey Pittman Developer - APS Medilink 2011/08/12

Microsoft Access 2010 Part 1: Introduction to Access

Building a Personal Website (Adapted from the Building a Town Website Student Guide 2003 Macromedia, Inc.)

How To Use Spss

No restrictions are placed upon the use of this list. Please notify us of any errors or omissions, thank you,

To Ac&vate Keyboard Apple Systems Preferences. Interna&onal Input Menu install them from an OS X CD Localized Files Switch Keyboards

SharePoint Rollins College 2011

EXCEL PIVOT TABLE David Geffen School of Medicine, UCLA Dean s Office Oct 2002

Personal Geodatabase 101

Web Ambassador Training on the CMS

Microsoft Access 2010 Overview of Basics

Tutorial Guide to the IS Unix Service

Introduction to PASW Statistics

How To Use Query Console

Using the GroupWise Client

Cisco Networking Academy Program Curriculum Scope & Sequence. Fundamentals of UNIX version 2.0 (July, 2002)

Login: Quick Guide for dotcms & Accessibility November 2014 Training:

Cal Poly Pomona Cascade Server Beginning Web Author Training

Getting Started with the SAS System Point and Click Approach

Decision Support AITS University Administration. EDDIE 4.1 User Guide

CentralMass DataCommon

Horizon Debt Collect. User s and Administrator s Guide

Most of your tasks in Windows XP will involve working with information

Introduction to SAS Business Intelligence/Enterprise Guide Alex Dmitrienko, Ph.D., Eli Lilly and Company, Indianapolis, IN

Stores copies of items you sent to others, by default. Stores items created offline that you want to send the next time you are online

To change title of module, click on settings

MICROSOFT OUTLOOK 2010 WORK WITH CONTACTS

EXST SAS Lab Lab #4: Data input and dataset modifications

Web Content Management Training Manualv3

Outlook Web Access User Guide

14.1. bs^ir^qfkd=obcib`qflk= Ñçê=emI=rkfuI=~åÇ=léÉåsjp=eçëíë

Analyzing the Server Log

OvidSP Quick Reference Guide

Introduction. Chapter 1

STATGRAPHICS Online. Statistical Analysis and Data Visualization System. Revised 6/21/2012. Copyright 2012 by StatPoint Technologies, Inc.

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

Settings 1 September 2015

Using This Reference Manual Chapter 1 to Issue ACL Commands

Oracle Fusion Middleware

Using Windows XP and File Management Handout (Staff)

Introduction to ROOT and data analysis

Hypercosm. Studio.

Transcription:

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

What is SAS Highly flexible and integrated soiware environment; you can use SAS for: GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 10

Base SAS The founda+on of SAS soiware is called Base SAS. GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 11

This course assumes that you are running Base SAS soiware in the windowing environment Which programming workspace am I using? Help > About GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 12

Set up prac+ce data To create a permanent SAS library named sasuser : Help > Learning SAS programming > OK GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 13

SAS program A SAS program is a data file that is formaaed in a way that SAS can understand. It can consist of one or more steps: a DATA step, a PROC step or any combina+on of the two GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 14

Data step With a Data step you can create or modify data sets: You use a Data step for: Put your data in a SAS dataset Compute values Check for and correct errors in your data Produce new SAS datasets by subsepng, supersepng, merging and upda+ng exis+ng data GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 15

Proc Step Invoke prewriaen rou+nes that enable you to analyze and process the data in a SAS dataset You can use PROC setps to: Create a report that lists the data Produce decrip+ve sta+s+cs Create a summary report Produce plot and chart GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 16

Generally a program involves a combina+on of the two steps like this: GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 17

SAS Statements A SAS program consists of statements A SAS statement: Usually begins with a SAS keyword Always ends with a semicolon GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 18

A SAS program GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 19

Understanding a SAS program Tree steps.. GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 20

.. 13 statements.. GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 21

.. Among them two global statements : Global statements are allalonestatements. 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. GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 22

SAS statements are free format They can begin and end anywhere on a line A statement can con+nue on several lines Several statements can be on the same line Blanks or special characters separare words in a SAS statement GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 23

Processing a program DATA sasuser.admit2; SET sasuser.admit; WHERE age>39; RUN; Bounderies of a step: PROC PRINT DATA=sasuser.admit2; A step begins by DATA or PROC statements RUN; A step ends by RUN or QUIT statement (although the RUN statement is not always required between steps, using it can make the SAS program easier to read and debug) At the step boundary, SAS: i) executes any statements that have not previously executed ii) ends the step Steps are submiaed in Enhanced Editor or in Program Editor windows When you submit a program, SAS execute it step by step. A log is generated in the Log window (for both PROC and DATA steps) Reports are generated in Output (as a list) and in Results Viewer (in HTML) windows for most of PROC steps (excep+ons: copy, sort...). You can find reports also in Results window. GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 24

Report Window Some SAS program open an interac+ve window, such as a REPORT window. You can use this window to directly modify data PROC REPORT DATA=sasuser.admit WINDOWS; COLUMNS id nams sex age actlevel; RUN; GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 25

Programming workspace: Editor Windows Enhanced Editor Features: Program Editor Features: Opening SAS programs Entering, edi+ng and submipng SAS programs Using the command line or menus Saving SAS programs Clearing contents Opening SAS programs Entering, edi+ng and submipng SAS programs Using the command line or menus Saving SAS programs Clearing contents Color Coding and sintax checking Expandable and collapsibile sec+ons Recordable macros Support for keyboard shortcuts Mul+level undo and redo Recalling Submiaed statements For clear any of these windows, when the window is ac+ve: Edit > Clear all GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 26

Programming workspace: Editor Windows GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 27

Sepng result formats Two formats: Lis+ng and HTML. Different versions, different default. Tools > Op+ons > Preferences > Results Both HTML and LISTING are the default in SAS 9.3 in Windows and UNIX Just HTML is the default in SAS 9.4 in Windows and UNIX In other plavorms, you have just LISTING mode, but you can create HTML output using programming statements You can choose to show the HTML output in another browser GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 28

The Log windows The Log window displays messages about your SAS session and about any SAS programs that you submit. To display this window : View > Log To clear this window : Edit > Clear all GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 29

The output windows The Output and Result Viewer windows list output from SAS program that you submit. Output shows results in LISTING mode, Results Viewer shows results in HTML mode By default they are behind the editor and the log windows. When you create output, they automa+cally move to the front of your display (Output behind Result Viewer). To display output window : View > Output The Results window lists and arranges in a tree structure the output. It allows browsing output easily It allows viewing, saving and prin+ng individual items of output It dislays separate icons for LISTING and HTML outputs To display this window : View > Results GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 30

The explorer window The Explorer window allows you to view and manage SAS files (in the libraries) but also nonsas (external) files. create new libraries and SAS files Moving, coping and dele+ng files Create shortcuts to external files. To display this window : View > Explorer GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 31

SAS Libraries A SAS library is a collec+on of SAS files stored in the same directory Temporary SAS libraries last only for the current session Permanent SAS Libraries are available during subsequent sessions GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 32

Referring a SAS dataset Two level (divided by a period) names: libref dataset name They refer to the same (temporary) library GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 33

If you don t specify a library name when you create a file (or you specify the library name Work), the file is stored in the temporary SAS data library GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 34

Rules for SAS filenames and libref Filename Can be 1 to 32 characters long Must begin with a leaer (uppercase or lowercase) or an underscore Can con+nue with any combina+on of numbers, leaers or underscores Ex: Payroll, LABDATA1995_1997, E+matedTaxPayments3 Libref Can be 1 to 8 characters long Must begin with a leaer (uppercase or lowercase) or an underscore Can con+nue with any combina+on of numbers, leaers or underscores GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 35

SAS Datasets A SAS Dataset is a file that consists of two parts: a descriptor por,on and a data por,on GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 36

Descrip+on por+on PROC CONTENTS DATA=sasuser.insure; RUN; Name of the dataset Date and +me the dataset was created The number of observa+ons The number of variables The properies (akributes) of each variable GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 37

Variable Aaributes: Name Variable Name, as the File Name: Can be 1 to 32 characters long Must begin with a leaer (uppercase or lowercase) or an underscore Can con+nue with any combina+on of numbers, leaers or underscores GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 38

Variable Aaributes: Type Can contain any values A blank represents a missing value for character variables Can contain only numeric values A period represents a missing value for numeric variables GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 39

Variable Aaributes: Length Length is measured in bytes (1 character > 1 byte) Numeric variables are stored by default in 8 bytes GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 40

Variable aaributes: Format & Informat Format indicates how a data value is displayed by SAS Ex: To display the value 1234 as $1,234.00 you can use the DOLLAR8.2 format Informat indicates how a raw data value is read by SAS in order to be converted in a SAS data value Ex: $12,345.00 contains two special characters. You can use informat op+on COMMA10. for removing dollar symbol and comma, in order to store 12345 as a numeric value GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 41

Variable aaributes: Label The label is a descrip+ve text up to 256 character long GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 42

Data por+on It is a collec+on of values arranged in a rectangular table PROC PRINT DATA=sasuser.insure noobs; RUN; GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 43

File Shortcuts You can create a file shortcut to an external file and store it in the File Shortcuts folder in the Explorer window. fileref is an op+onal name that is used to iden+fy an external file in SAS. you can se a file shortcut to open browse and submit a file When you delete a file shortcut, the pointer to the file is deleted. However the file s+ll exists in its phisical loca+on GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 44

Help Using this window is a task oriented help referring to the ac+ve window. Other op+ons of the help menu: Sas help and Documenta+on (complete guide to SAS) Gepng started tutorials Learning SAS programming (create dataset used in training) SAS on the web (technical support) GIORGIO RUSSOLILLO Cours de prépara+on à la cer+fica+on SAS «Base Programming» 45