Last modified on 27 September 2006, at 13:13

User:BrisbanePom

My Sandbox. Planning to create a SAS programming Wikibook. Using Ada programming as a template; once I have something workable in place, I will launch the book.

Template:Programmingnav


File:SAS logo.jpg
Logo of The SAS Institute, vendor of the SAS system.


Welcome to the SAS Programming tutorial at Wikibooks. This book was started in August 2006 to provide a template for the first foray into SAS programming in the Wikibooks world. It is hoped that memebrs of the SAS development community will recognise the value in having a centralised teaching resource for SAS programming and contribute accordingly. In particular, links to the many papers presented at various SAS conferences around the world and over the years are very much encouraged.

Current Development Stage for SAS Programming is "0% developed  as of Aug 7, 2005 (Aug 7, 2005)". It's a lengthy road ahead, but it has to begin somewhere!

Please feel free to contribute (that's what a Wikibook is all about) and please spread the word amongst SAS developers everywhere that this book is now here.

About SASEdit

The SAS System, (originally referring to the Statistical Analysis System), is an integrated suite of software products used to perform a number of data and statistical analysis operations. Whilst specialist sub-products exist within the SAS Sytem, some of which use a graphical interface (e.g. the data-mining tool SAS Enterprise Miner), the core programming language that underpins all of these tools is Base SAS.

In addition, the SAS System integrates with many SAS business solutions that enable large scale software solutions for areas such as human resource management, financial management, business intelligence, customer relationship management and more.

Description of SASEdit

File:SAS 8 on IBM Mainframe3.png
SAS 8 on an IBM Mainframe under 3270 emulation

SAS is driven by SAS programs that define a sequence of operations to be performed on data stored as tables. Although non-programmer graphical user interfaces to SAS exist (such as the SAS Enterprise Guide), most of the time these GUIs are just a front-end to automate or facilitate generation of SAS programs. SAS components expose their functionalities via application programming interfaces, in the form of statements and procedures.

A SAS program is composed of three major parts, the DATA step, procedure steps (effectively, everything that is not enclosed in a DATA step), and a macro language. SAS Library Engines and Remote Library Services allow access to data stored in external data structures and on remote computer platforms.

The DATA step section of a SAS program, like other database-oriented fourth-generation programming languages such as SQL or Focus, assumes a default file structure, and automates the process of identifying files to the operating system, opening the input file, reading the next record, opening the output file, writing the next record, and closing the files. This allows the user/programmer to concentrate on the details of working with the data within each record, in effect working almost entirely within an implicit program loop that runs for each record.

All other tasks are accomplished by procedures that operate on the dataset (SAS' terminology for "table") as a whole. Typical tasks include printing or performing statistical analysis, and may just require the user/programmer to identify the dataset. Procedures are not restricted to only one behavior and thus allow extensive customization, controlled by mini-languages defined within the procedures. SAS also has an extensive SQL procedure, allowing SQL programmers to use the system with little additional knowledge.

There are macro programming extensions, that allow for rationalization of repetitive sections of the program. Proper imperative and procedural programming constructs can be simulated by use of the "open code" macros or the SAS/IML component.

Macro code in a SAS program, if any, undergoes preprocessing. At runtime, DATA steps are compiled and procedures are interpreted and run in the sequence they appear in the SAS program. A SAS program requires the SAS System to run.

Compared to general-purpose programming languages, this structure allows the user/programmer to be less familiar with the technical details of the data and how it is stored, and relatively more familiar with the information contained in the data. This blurs the line between user and programmer, appealing to individuals who fall more into the 'business' or 'research' area and less in the 'information technology' area, since SAS does not enforce (although SAS recommends) a structured, centralized approach to data and infrastructure management.

The SAS System runs on IBM mainframes, Unix machines, OpenVMS Alpha, and Microsoft Windows; and code is almost transparently moved between these environments. Older versions have supported PC-DOS, the Apple Macintosh, VMS, VM/CMS and OS/2.

Programming in Base SASEdit

Introduction to SASEdit

An overview of the wider SAS system and it's role in businesses today, followed by an introduction to the Base SAS product and a description of the SAS programming language in comparison to more 'traditional' languages.

  • Overview of the SAS system — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • Introduction to Base SAS — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • Basic language concepts — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)

Basic Data manipulationEdit

These chapters look at the first steps needed to handle data using SAS.

  • Importing and creating data — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • The data step - fundamental functions and statements — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • Essential SAS procedures - sorting and summarising data — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • Modifying and combining data sets (Merge, Set, Transpose) — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • Generation of data output and exporting data — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)

Making the most of Base SAS; advanced conceptsEdit

Beyond the basic data handling concepts outlined in the previous chapters, Base SAS offers powerful functionality to the user. In addition to a wealth of statistical procedures, SAS is supported b a macro language to enable users to automate program execution. Recent developments with the ODS system allow users to create professional graphical and web output.

  • The Enhanced Editor - managing the programming environment — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • Statistical and advanced procedures in Base SAS — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • Automating data steps - the SAS Macro language — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • Generating output using the Output Delivery System (ODS) — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • Manipulating variables through the use of arrays — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)

Beyond Base SASEdit

Base SAS is only the beginning of learning to use SAS; a host of specialist products also exist to perform advanced tasks. These chapters give an overview and focus on some of the key products you may encounter.

  • Overview of other SAS modules — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • SAS/STAT — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • SAS/Graph — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • SAS/Access and SAS/Connect — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • SAS/Enterprise Guide — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • Data mining with SAS/Enterprise Miner — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • Other SAS products — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)

External resourcesEdit

Collections of Links to various SAS user websites and presented conference papers.

  • SAS user groups and user pages — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • Index of referenced conference papers — 0% developed  as of Sep 14, 2006 (Sep 14, 2006)
  • SAS-L at University of Georgia (SAS User helproom)

Authors and contributorsEdit

This Wikibook has been written by:

If you wish to contribute as well you should read Contributing and join us at the Contributors lounge.