“Know your data”. A tired, old phrase you have probably heard a million times before. Nevertheless, it is very important. Especially in SAS programming. Having a clear view of what your data looks like is essential, regardless of what you want to do with it. You should familiarize yourself with the data you work with. For this purpose, SAS procedures like PROC DATASETS, PROC CONTENTS and PROC COMPARE are invaluable. Many of the examples below take advantage of the numerous features of these procedures.
However, it is not enough to familiarize yourself with what the data looks like now. It is equally important to know how to reshape it. Different tasks in SAS require different datashapes. Therefore, it is important to know how to manipulate datasets efficiently. You should know what tool to use when.
The data step and the various available procedures makes virtually any data manipulation task possible. On this page, I present code examples of common issues and how to solve them efficiently in SAS.
Data Science Code Examples
Learning the basics of how to manipulate datasets is fundamental for almost everything else in SAS. If you do not know how to shape and manipulate your data, you will have a hard time doing statistical analysis, graphing or what you might think of doing in your SAS code. The Data Step is an essential part of this. For a great introduction to data step processing and much more, I encourage you to take the Programming 1 E-Learning Course provided for free by SAS Institute. For other learning materials, see my Learn SAS Programming page.
Finally, I have a few related examples on my blog as well. See them all in the Data Category.