SAS Programming Professionals,
Did you know that you can get PROC REPORT to “jump start” itself?
The breadth and scope of the SAS programming language makes it a challenge to remember the exact syntax of every procedure. So, many of us use shortcuts whenever we can find them. One such shortcut is the LIST option in PROC REPORT. The LIST option directs SAS to write the PROC REPORT code to the log… without line numbers!
So, this SAS code:
proc report data=sashelp.class list noexec;
…produces this log entry:
1 proc report data=sashelp.class list noexec;
PROC REPORT DATA=SASHELP.CLASS LS=96 PS=54 SPLIT="/" CENTER ;
COLUMN Name Sex Age Height Weight;
DEFINE Name / DISPLAY FORMAT= $8. WIDTH=8 SPACING=2 LEFT "Name" ;
DEFINE Sex / DISPLAY FORMAT= $1. WIDTH=1 SPACING=2 LEFT "Sex" ;
DEFINE Age / SUM FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "Age" ;
DEFINE Height / SUM FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "Height" ;
DEFINE Weight / SUM FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "Weight" ;
We can now cut-n-paste the PROC REPORT code from the log into a SAS program and edit it to make a perfect report for our project. Not bad, eh?
Wondering about the NOEXEC option? Not surprisingly, that option tells SAS NOT to execute the REPORT procedure and create a report. Might as well save a few CPU cycles whenever we can!
Best of luck in all your SAS endeavors!
(aka Michael A. Raithel)
Excerpt from the book: Did You Know That? Essential Hacks for Clever SAS Programmers
I plan to post each and every one of the hacks in the book to social media on a weekly basis. Please pass them along to colleagues who you know would benefit.