In my previous post, I revealed my top 5 hits from Programming 1: Essentials. Now that you’ve gotten into the programming groove, I’ll share my greatest hits from Programming 2: Data Manipulation Techniques; using real song titles to describe each one … sing with me now!
- We Gotta Get Outta this Place (Explicit Output)
The DATA step will output observations for you without your even having to ask (gee, thanks DATA step!) But sometimes you'll need to step in and get bossy in order to get the results you want. For example, you might need to output multiple times in the same iteration or output to multiple datasets (see song title #2 below). Explicit output to the rescue.
- Go Your Own Way (Writing to Multiple SAS Datasets)
What to do when you need to create multiple datasets from the same source file(s)? You can certainly create each dataset in its own step, but it's much more efficient to create them all in a single step and one pass of the data.
- Fix You (Converting Variable Type)
Suppose the newly hired SAS programmer down the hall gives you a dataset with dates stored as character values, but you need to do some calculations using numeric SAS date values. Or you need to merge two datasets but one of the by- or key variables is numeric in one dataset and character in the other. You'll need to convert variable type, and after taking Programming 2, you'll know all of the details.
- Do It Again (Processing Data Iteratively)
Compared to my other favorites, this one is "Bohemian Rhapsody" (meaning, it's longer and has several different parts). So I won't try to give examples of where you will use these techniques: that would take too long. I'll just say that I don't know how I could solve many challenging data manipulation problems without them. Once you learn these methods, you'll be doing the fandango (at least from a SAS programming perspective)!
- The Twist (Rotating with the DATA Step)
I love this material in part because it illustrates something that you will likely need to do at some point (converting rows to columns or vice-versa), but also because it illustrates the amazing flexibility of the DATA step. With the right selection and sequence of statements and options, you can get the results you need.
So, there you have it. My faves from the set list of our latest SAS Training Roadshow. There are still seats available, so maybe we’ll see you as we round out our seven city tour. Check out the upcoming dates for Baltimore, Cleveland, St. Louis, Portland, Salt Lake City, San Diego & San Jose.