SASSAS | The Leader in Business Intelligence -- Superior Software that gives you The Power to Know
  NewsEventsConsultingCareersContact UsResource Center
Home Products and Solutions Customers Partners Company Customer Support
 
Products and Solutions
Industries
Small to Medium Business
Analytics
Business Intelligence
Compliance
Customer Relationship Mgmt.
Data Integration
Financial Intelligence
Foundation Tools
Human Capital Intelligence
IT Management
OnDemand Solutions
Performance Management
Risk Management
Supply Chain Intelligence
Sustainability Management
Product Index A-Z
 
SAS/TOOLKIT®

SAS/TOOLKIT software enables you to write your own customized SAS procedures (including graphics procedures), informats, formats, functions (including IML and DATA step functions), CALL routines, and database engines in several languages including C, FORTRAN, PL/I, and IBM assembler.

SAS Procedures

A SAS procedure is a program that interfaces with the SAS System to perform a given action. The SAS System provides services to the procedure such as:
  • statement processing
  • data set management
  • memory allocation

SAS procedures can read SAS data sets and data views, perform data analysis, print results, and create other SAS data sets. There are many advantages to writing programs as SAS procedures rather than stand-alone programs:
  • Familiarity -- using your new procedure is easy for SAS users because they already understand data input, data manipulation, and general SAS syntax.
  • Extensibility -- you can extend the capabilities of the SAS System to meet the specialized needs of your users.
  • Convenience -- a program incorporated into the SAS System allows you to put all your programming tools in one place.
  • Reduced Coding -- the SAS System provides many services that you, as the programmer, would otherwise have to code yourself.
  • Integration -- the data used by your procedure can easily be sorted, printed, and analyzed using other SAS procedures during a single job.
  • Special Capabilities -- special features, such as BY-group processing, can be used.
  • Reduced Documentation -- the task of documenting your new program is simplified because only the new language statements, the procedure's output, and any special calculations need to be explained.

Writing SAS Procedures

If you are considering writing a SAS procedure, you probably have in mind what you want the procedure to do. Determining function and purpose and planning your program are important preliminaries to writing SAS procedures.

Writing the Grammar

One of the important parts of planning your procedure is deciding how the user will invoke it. You must have this information to write the grammar for the procedure. The grammar defines the format of the PROC statement, the other statements that can be used when invoking the procedure, and any options that can be used in the PROC or other statements. The SAS System uses the syntax rules you define in the grammar to check the syntax of the statements when the user invokes the procedure.

Writing the Procedure

The biggest task of procedure writing is coding the application program that actually performs the function of the procedure. To assist you in coding the procedure, the software provides a library of routines that enable you to interface with the SAS System and perform frequently needed tasks. The library routines are grouped into sets that perform related actions. For example, there are sets of routines for all of the following tasks:
  • perform I/O on SAS data sets
  • dynamically allocate memory for use by your program
  • print procedure output or messages to the SAS log
  • provide detailed information on observations and variables in SAS data sets
  • handle problems specific to the SAS environment, such as missing values
  • replace routines standard to the programming language you are using when the standard routines do not properly interface with the SAS System.

SAS Informats, Formats, Functions, and CALL Routines (IFFCs)

You can use SAS/TOOLKIT software to write your own SAS informats, formats, functions, and CALLroutines in the same choice of languages: C, FORTRAN, PL/I, and IBM assembler.

Like procedures, user-written functions and CALL routines add capabilities to the SAS System that enable you to tailor the system to your site's specific needs. Many of the same reasons for writing procedures also apply to writing SAS formats and CALL routines.

SAS/TOOLKIT Software and PROC FORMAT

You may wonder why you should use SAS/TOOLKIT software to create user-written formats and informats when base SAS software includes PROC FORMAT. SAS/TOOLKIT software enables you to create formats and informats that perform more than the simple table lookup functions provided by the FORMAT procedure. When you write formats and informats with SAS/TOOLKIT software, you can do the following:
  • assign values according to an algorithm instead of looking up a value in a table. You can include calculations and other algorithmic capabilities in your formats and informats that you write with the software.
  • look up values in a Database to assign formatted values. To create a format with ranges and labels that are derived from a database, you have to extract the ranges and labels from the database using external means, and create a flat file containing the values. Then, you read in the flat file and create a CNTLIN= data set to be read by PROC FORMAT. SAS/TOOLKIT software allows you to use routines provided by the database software to extract the data directly, and avoid processing all the data values.

Writing a SAS IFFC

Unlike SAS procedures, IFFCs do not require that you define a grammar module. In general, IFFCs are simpler and shorter than user-written procedures. You do not need to interface with the SAS System as much in an IFFC, but when you do, you can use the same library of routines that are available for procedures. The routines you are most likely to use when writing an IFFC perform the following tasks:
  • provide a mechanism to interface with functions that are already written at your site
  • use algorithms to implement existing programs
  • handle problems specific to the SAS environment, such as missing values.

SAS Engines

SAS engines allow data to be presented to the SAS System so it appears to be a standard SAS data set. Engines supplied by SAS Institute consist of a large number of subroutines, all of which are called by the portion of the SAS System known as the engine supervisor. However, with SAS/TOOLKIT software, an additional level of software, the engine middle-manager simplifies how you write your user-written engine.

An Engine versus a Procedure

To process data from an external file, you can write either an engine or a SAS procedure. In general, it is a good idea to implement data extraction mechanisms as procedures instead of engines. If your applications need to read most or all of a data file, you should consider creating a procedure—-but if they need random access to the file, you should consider creating an engine.

Writing SAS Engines

When you write an engine, you must include in your program a prescribed set of routines to perform the various tasks required to access the file and interact with the SAS System. These routines:
  • open and close the data set
  • obtain information about variables
  • provide information about an external file or database
  • read and write observations.

In addition, your program uses several structures defined by the SAS System for storing information needed by the engine and the SAS System. The SAS System interacts with your engine through the SAS engine middle-manager.

Using the USERPROC Procedure

Before you run your grammar, procedure, IFFC, or engine, use SAS/TOOLKIT software's USERPROC procedure.
  • For grammars, the USERPROC procedure produces a grammar function.
  • For procedures, IFFCs, and engines, the USERPROC procedure produces a program constants object file, which is necessary for linking all of the compiled object files into an executable module.

Compile and link the output of PROC USERPROC with the SAS System so that the system can access the procedure, IFFC, or engine when a user invokes it.

Using User-Written Procedures, IFFCs, and Engines

After you have created a SAS procedure, IFFC, or engine, you need to tell the SAS System where to find the module in order to run it. You can store your executable modules in any appropriate library. Before you invoke the SAS System, use operating system control language to specify the fileref SASLIB for the directory or load library where your executables are stored. When you invoke the SAS System and use the name of your procedure, IFFC, or engine, the SAS System checks its own libraries first and then looks in the SASLIB library for a module with that name.

Debugging Capabilities

The TLKTDBG facility allows you to obtain debug information concerning SAS routines called by your code, and works with any of the supported programming languages. You can turn this facility on and off without having to recompile or relink your code. Debug messages are sent to the SAS log.

In addition to the SAS/TOOLKIT internal debugger, the C language compiler used to create your extension to the SAS System can be used to debug your program. The SAS/C Compiler, the VMS Compiler, and the dbx debugger for AIX can all be used.

NOTE: SAS/TOOLKIT software is used to develop procedures, IFFCs, and engines. Users do not need to license SAS/TOOLKIT software to run procedures developed with the software.

The Power to Know
   Contact Us      Worldwide Sites     Search     Site Map     RSS Feeds     Terms of Use    Privacy Statement   Copyright © 2008 SAS Institute Inc. All Rights Reserved