6SAS® ADVANCED PROGRAMMING TOPICS PART 1

The SAS programming language is extensive and flexible, and there are many features of the language that were not discussed in the previous chapters of this book. The next two chapters are included for those who want to go deeper into SAS programming. This chapter introduces several topics that are commonly used in preparing data for analysis not covered in previous chapters. Additional programming topics including arrays and macros are covered in Chapter 7.

6.1 USING SAS FUNCTIONS

Sophisticated calculations can be created using SAS functions. These functions include arithmetic and text and date manipulation. The format for the use of SAS functions is

variable = function(argument1,argument2, etc.);

Functions can require one or more arguments. Some require no arguments.

For example, a few mathematical functions in SAS are as follows:

S = ABS(X); Absolute value
S = FACT(X); Factorial
S = INT(X); Integer portion of a value
S = LOG(X); Natural log
S = SQRT(X); Square root

Some of the other functions available in SAS are SUBSTR, LAG, COS, SIN, ARCS, LOG10, UNIFORM, NORMAL, SUM, and MEAN. A list of commonly used SAS functions and additional examples can be found in Appendix B. These include functions of these types: ...

Get SAS Essentials: Mastering SAS for Data Analytics, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.