Hemken / SASmarkdown

A collection of R functions that extends knitr's capability for using SAS as a language engine
Other
21 stars 5 forks source link

SASmarkdown fails when there is a syntax error in SAS code #6

Closed mgdondon closed 6 years ago

mgdondon commented 6 years ago

Hello,

SASmarkdown package is OK when SAS code is OK:

knitr::opts_chunk$set(echo = TRUE)
require(SASmarkdown)
## Loading required package: SASmarkdown

## sas, saslog, sashtml, and sashtmllog engines

##    are now ready to use.
saspath <- "C:/Program Files/SASHome/SASFoundation/9.4/sas.exe"
sasopts <- "-nosplash -ls 75"
knitr::opts_chunk$set(engine='sas', engine.path=saspath,
                      engine.opts=sasopts, comment="")
proc means data=sashelp.class;
run;
                              Procédure MEANS

 Variable    N        Moyenne     Ecart-type        Minimum        Maximum
 -------------------------------------------------------------------------
 Age        19     13.3157895      1.4926722     11.0000000     16.0000000
 Height     19     62.3368421      5.1270752     51.3000000     72.0000000
 Weight     19    100.0263158     22.7739335     50.5000000    150.0000000
 -------------------------------------------------------------------------

but fails when there is a syntax error in SAS :

proc means data sashelp.class;
run;

sasmarkdown_error


It would be usefull to get the SAS log as with SASKernel:

proc means data sashelp.class;
run;
SAS Connection established. Subprocess id is 6648

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

6                                                          Le Système SAS                         15:53 Thursday, September 13, 2018

39 ods listing close;ods html5 (id=saspy_internal) file=_tomods1 options(bitmap_mode='inline') device=svg style=HTMLBlue;
39 ! ods graphics on / outputfmt=png;
NOTE: Writing HTML5(SASPY_INTERNAL) Body file: _TOMODS1
40
41 proc means data sashelp.class;
_____________
73
ERROR 73-322: Un(e) = est attendu(e).
42 run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

43
44 ods html5 (id=saspy_internal) close;ods listing;
45

Thanks,

mgdondon commented 6 years ago

Sorry, it's related to issue #3 and therefore OK.

```{r, engine='sas', error=TRUE}
proc means data sashelp.class;
run;
2 proc means data sashelp.class;
_____________
73
ERROR 73-322: Un(e) = est attendu(e).
3 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: Errors printed on page 1

Thanks,

Hemken commented 6 years ago

Sorry for the slow response, and glad you found the solution. I considered making error=TRUE a default, but I guess I decided to keep this consistent with the rest of knitr.

However, you do remind me that I need to set up an HTML5 engine! Thanks.