Rick Wicklin dropped a gem today! The SAS enhanced editor includes a text replacement feature– who knew? The use of it is laid out in this SAS paper.
Briefly, just click on Tools > Add Abbreviation, then type in the shortcut and the tex…
Tag: SAS tricks
Clear the Results viewer in SAS 9.3
The Problem
The new default output destination in SAS 9.3 is the “Results Viewer” rather than the “Listing” window. The results viewer shows an html file that integrates text and graphical output. It’s pretty, and it’s very nice (sometim…
Read a sheet from an Excel file
Yet another useful not-a-trick.
One of the great things about SAS is the accessibility and completeness of the documentation. However, occasionally lapses in the completeness do come up.
One example is in importing data. A primary …
The "do over" syntax for arrays
This is another useful not-a-trick.
No longer to be found in the documentation is the “do over” syntax, which can simplify code and keep datasets narrower. The syntax works like this:
data …;array arrayname x y z var1 – var3; do over arra…
Example 8.13: Bike ride plot, part 2
Before explaining how to make and interpret the plot above, Nick and I want to make a plea for questions–it’s hard to come up with useful questions to explore each week!As shown in Example 8.12, data from the Cyclemeter app can be used to make interes…
Get where condition into the output
The where statement is a powerful and useful tool for subsetting on the fly. But one problem with it is that the output doesn’t show the conditioning. This is a little macro I wrote to correct this problem:%macro where(wherest, titleline);w…
Print global macro variables
The call symput(“macroname”, varname) is really useful for getting data from a data set into SAS code that’s executed later. One example is shown here.
This entry is inspired by a simulation project I’m coding right now where there are many…
Convert data to CSV file
In addition to the export file wizard and proc export (section 1.2.3 of SAS and R), SAS provides a the nifty little %ds2csv macro that can do this quickly and easily.
The advantages to this approach are that there are a few extra options and that…