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.
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 "". 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.
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
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 —
- Introduction to Base SAS —
- Basic language concepts —
Basic Data manipulationEdit
These chapters look at the first steps needed to handle data using SAS.
- Importing and creating data —
- The data step - fundamental functions and statements —
- Essential SAS procedures - sorting and summarising data —
- Modifying and combining data sets (Merge, Set, Transpose) —
- Generation of data output and exporting data —
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 —
- Statistical and advanced procedures in Base SAS —
- Automating data steps - the SAS Macro language —
- Generating output using the Output Delivery System (ODS) —
- Manipulating variables through the use of arrays —
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 —
- SAS/STAT —
- SAS/Graph —
- SAS/Access and SAS/Connect —
- SAS/Enterprise Guide —
- Data mining with SAS/Enterprise Miner —
- Other SAS products —
Collections of Links to various SAS user websites and presented conference papers.
- SAS user groups and user pages —
- Index of referenced conference papers —
- SAS-L at University of Georgia (SAS User helproom)