6 Cleaning Up SAS Log Output

6.1 Intro

To gain more control over just what part of the SAS log we show the reader, we have several options. If you are fluent in SAS, it will probably occur to you that there are SAS options to

  • suppress NOTES (options NONOTES;)
  • suppress just the procedure time (options NOSTIMER;)
  • suppress the source code echo (options NOSOURCE;),
  • as well as an option to tune how verbose the ERROR messages are (options ERROR=0; or more).
  • (There is no option to suppress WARNINGs.)

6.2 Setup

Set up your document by loading SASmarkdown.

library(SASmarkdown)

6.3 Default Log

First, consider an example using the saslog engine without any of these options, giving us the default log output:

```{saslog} 
proc means data=sashelp.class(keep=height);
run;
```

The result is:

2          proc means data=sashelp.class(keep=height);
3          run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The PROCEDURE MEANS printed page 1.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.55 seconds
      cpu time            0.01 seconds
      
                            The MEANS Procedure

                        Analysis Variable : Height 
 
     N            Mean         Std Dev         Minimum         Maximum
    ------------------------------------------------------------------
    19      62.3368421       5.1270752      51.3000000      72.0000000
    ------------------------------------------------------------------

6.4 Global Cleanup

To clean up the SAS log for every code chunk in your document, add the appropriate SAS option to the SASmarkdown engine options in an R chunk.

```{r} 
sasopts <- "-nosplash -ls 75 -nonotes"
knitr::opts_chunk$set(engine.opts=list(sas=sasopts, saslog=sasopts))
```

Repeating our SAS example, the result now looks like this:

2          proc means data=sashelp.class(keep=height);
3          run;
                            The MEANS Procedure

                        Analysis Variable : Height 
 
     N            Mean         Std Dev         Minimum         Maximum
    ------------------------------------------------------------------
    19      62.3368421       5.1270752      51.3000000      72.0000000
    ------------------------------------------------------------------

6.5 Chunk Cleanup

There are two ways to cleanup the log per chunk. The “SAS” way is to include a cleanup option in your code chunk. (You can hide this option from your readers with the echo=-1 chunk option.)

```{saslog, echo=-1} 
options nostimer;
proc means data=sashelp.class(keep=height);
run;
```

Modifying our SAS example with a different option, the result looks like this:

3          proc means data=sashelp.class(keep=height);
4          run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The PROCEDURE MEANS printed page 1.
                            The MEANS Procedure

                        Analysis Variable : Height 
 
     N            Mean         Std Dev         Minimum         Maximum
    ------------------------------------------------------------------
    19      62.3368421       5.1270752      51.3000000      72.0000000
    ------------------------------------------------------------------

(Notice that SAS’ TIMER is also a NOTE.)

6.5.1 SASproctime

Then, to suppress the procedure time notes your code chunk looks like this:

```{saslog notimer, SASproctime=FALSE} 
proc means data=sashelp.class(keep=height);
run;
```

In your document, the result looks like this:

2          proc means data=sashelp.class(keep=height);
3              run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The PROCEDURE MEANS printed page 1.

The other two options work in a similar manner.

6.5.2 SASecho

This suppresses the code echo.

```{saslog noecho, SASecho=FALSE, results="hide"} 
proc means data=sashelp.class(keep=height);
run;
```

In your document, the result looks like this:

1                             The SAS System

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The PROCEDURE MEANS printed page 1.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.58 seconds
      cpu time            0.03 seconds
      

6.5.3 SASnotes

This suppresses the notes.

```{saslog nonotes, SASnotes=FALSE, results="hide"} 
proc means data=sashelp.class(keep=height);
run;
```

In your document, the result looks like this:

2          proc means data=sashelp.class(keep=height);
3              run;

Written using

  • SASmarkdown version 0.8.0.
  • knitr version 1.40.
  • R version 4.2.2 (2022-10-31 ucrt).