I’ve spent quite a while now going through chapter 8, “Creating Enhanced List and Summary Reports,” in the Base Certification Prep Guide. This topic should be straightforward, I keep telling myself. So why did I score 40% on the quiz?
Thinking that I probably needed to delve a little deeper, I tried to complete the sample data and SAS programs associated with chapter 8 on the CD that comes with the Base Certification Guide. Although I got through the first seven topics with no problem (note to self: go through the sample data and SAS programs on the accompanying CD for all the chapters; they really help!), I got stuck on order variables, much as I did in the hard copy of the chapter itself.
Here is the sample code found on the CD:
It tells me to run the code and view the log and report. No problem! Then it says to modify the code to order rows in descending order of values of ID and then resubmit. So I do, by changing:
define id/ order;
define id/ orderdescending;
which I dutifully do, but it doesn’t seem to work. Nothing changes, and I check the log and see this:
What is up with the WARNING statement? “Assuming the symbol ORDER was misspelled as orderdescending.” I don’t understand why this wouldn’t work. So I try with it with a space between “order” and “descending,” and guess what? It works. Probably not a surprise to you, I know. At least in the version of the prep guide I’m using, it looks like no space is there. So I get clever and try to change it to “order ascending,” and I get a really scary error message. Is this because the default is ascending?
So I move on. This is awfully taxing for a Friday afternoon. Next assignment asks me to run this code and review the output:
The output looks like it did before. Which variable, it asks, is preventing PROC REPORT from collapsing observations? This was another concept I had trouble with. The solution, according to the CD, is to “remove ID from the COLUMN statement and delete the DEFINE statement for ID.” But what if I wanted ID in the columns?
The guide itself states: “The problem with the output is that your report contains display variables. As character variables, Orig and Dest are defined as display variables by default. All of the variables in a summary report must be defined as group, analysis, across, or computed variables. This is because PROC REPORT must be able to summarize all variables across an observation in order to collapse observations. If PROC REPORT can’t create groups, it displays group variables as order variables.”
Huh? So do I just remove the offending character variable from the columns included, or could I have just added “group” to precede “order” in the define statement? Clearly I am not getting this at all. Will someone explain this to me in another way so that I understand it?
This was the most challenging chapter so far, for me at least. And I haven’t even brought up the dreaded computed variables.
By the way, while you are reading blogs, surf on over to check out Renee Harper’s latest blog post, “Advice to a New SAS Programmer.” Renee saw an interesting question posted to Twitter by @sastips. She asked experienced SAS programmers what advice they would give to new or junior SAS programmers. Renee listed a few of the replies and asked for more, and many more have been added. I was heartened to see that the number-one tip was to get certified. Indeed. So please add any tips you have for us new SAS programmers in the comments section. Know that I’ll be reading!