Have you ever inherited a SAS program from a "gifted" SAS programmer? By "gifted", I mean a person who regards line feeds and white space as a waste of precious bytes, who knows that his program is worth the tremendous effort it might take to read and understand it, as if he's the William Faulkner of SAS programming?
Or maybe his theory is that an ugly program just works better, taking a page from Jimmy Soul on how to be happy for the rest of your life.
In SAS Enterprise Guide 4.3 (due out later this summer), we've added a "code formatter" feature that can take your densely formatted SAS program and tidy it up so that it's much easier to read.
We showed this off at SAS Global Forum in April, and one customer said, "Hey, I've got a really ugly program. I wonder what the formatter would do with it?" Note: In his defense, I don't think he wrote the program. I think he just lives with it, as many of us do. Here's a snippet from the program as it is:
I opened the program in SAS Enterprise Guide 4.3, pressed Ctrl+I (the shortcut key for "indent this!"), and in less than a second the entire scene was beautified. Here's the same snippet, reformatted:
If you want to see the entire program, before and after, follow these links:
By the way, I created the above-linked pages using another new feature: Export a SAS program as HTML. It's a great way to export your program and preserve the coloring and spacing for display within a web page. I don't know if anyone but me will use it, but that's worth it to me.
Here are common questions that people ask when we demonstrate the formatter feature:
- Can you control the style of formatting? Yes, to a limited extent. There aren't enough options to satisfy every preferred style, but as one programmer said, "if you format it for me, maybe I'll just change my style to match."
- What if I don't like the formatted version? Undo is just a click (or Ctrl+Z keystroke) away.
- Will this change the way my program works? Not at all. The only changes are made to code lines (not content such as DATALINES) and only indenting and line breaks for statements and logic constructs.
- What about macro programs? Yep, it will make those pretty too.
- Can I reformat just a portion of my program? Yes, simply select the desired lines, press Ctrl+I, and BOOM! -- just those lines are reformatted.
Do you have a SAS program that you consider, well, sort of homely looking? Are you curious what the formatter might do with it? Feel free to send it to me at Chris.Hemedinger [at]sas.com and I'll give it a whirl. (Don't submit it as a blog comment, since the original formatting would be lost. And please, no programs that contain company secrets, passwords, or proprietary algorithms you don't want to share.)