DS2 is a new object-oriented programming language introduced in SAS 9.4 that functions within a procedure (PROC). It is included with Base SAS so you can use it in SAS programming environments like SAS Enterprise Guide and SAS Studio.
DS2 is not necessarily meant to be a replacement for the Data Step, so don’t think that you have to convert all your existing programs to DS2. However, DS2 does have advantages in certain areas: additional data types, ANSI SQL types – FedSQL is a SAS implementation of the ANSI SQL types, programming structure elements, and user-defined methods and packages.
What Do You Need To Know about PROC DS2?
An updated Data Step
- New supported data types that follow most ANSI standards. This includes VARCHAR, INTEGER, FLOAT, BINARY, and other DATETIME data types. See here for the complete list.
- RUN/INIT/TERM are automatic system methods run for every DS2 program
- Executable code must be in a method
User Defined Methods
- Users can create their own methods to keep their program organized between calculations and processes
- User defined methods must be called in order to execute
- User defined methods can be defined within a reusable user defined package (class).
Parallel Processing with Threads
- Even though it still uses the implicit loop when processing a data step, DS2 can spread that process out across multiple threads.
- Threads can be useful if you have a bottleneck at the CPU processing level
Applying PROC DS2 To Your Code
Want to see an example of PROC DS2, check out the PROC DS2 First Impressions where I walk you through an example using warranty data.
For a deep dive into PROC DS2, read Mastering the SAS DS2 Procedure: Advanced Data Wrangling Techniques by Mark Jordan.