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

Sas execution stuck, command line seems to be sent twice #11

Closed gozeErG closed 4 years ago

gozeErG commented 4 years ago

Hello,

this is the first time I try to use Sasmardown. Thank you for letting us the opportunity to document Sas sources for students.

I try to run a very simple exemple for a start :


title: "Sas markdown test" author: "Goze" date: "27 novembre 2019" output: html_document

knitr::opts_chunk$set(echo = TRUE)
saspath <- "C:/Program Files/SASHome/SASFoundation/9.4/sas.exe"
sasopts <- "-nosplash -ls 75"
knitr::opts_chunk$set(engine.path=list(sas=saspath, saslog=saspath),
                      engine.opts=list(sas=sasopts, saslog=sasopts), 
                      comment=NA)
library(SASmarkdown)
proc means data=sashelp.class;
run;

processing file: Sas-markdown-test.Rmd |......... | 14% ordinary text without R code

|................... | 29% label: setup (with options) List of 1 $ include: logi FALSE

|............................ | 43% ordinary text without R code

|..................................... | 57% label: libload (with options) List of 1 $ echo: logi TRUE

|.............................................. | 71% ordinary text without R code

|........................................................ | 86% label: ex-sas (with options) List of 1 $ engine: chr "sashtml"

running: C:/Program Files/SASHome/SASFoundation/9.4/sas.exeC:/Program Files/SASHome/SASFoundation/9.4/sas.exe sas40ec2be11dc1.sas -nosplash -ls 75sas40ec2be11dc1.sas -nosplash -ls 75

For the moment,, Sas execution command hangs with the follwing output in th Rmarkdown tab :

processing file: Sas-markdown-test.Rmd |......... | 14% ordinary text without R code

|................... | 29% label: setup (with options) List of 1 $ include: logi FALSE

|............................ | 43% ordinary text without R code

|..................................... | 57% label: libload (with options) List of 1 $ echo: logi TRUE

|.............................................. | 71% ordinary text without R code

|........................................................ | 86% label: ex-sas (with options) List of 1 $ engine: chr "sashtml"

running: C:/Program Files/SASHome/SASFoundation/9.4/sas.exeC:/Program Files/SASHome/SASFoundation/9.4/sas.exe sas40ec2be11dc1.sas -nosplash -ls 75sas40ec2be11dc1.sas -nosplash -ls 75

Cheers,

Eric

Hemken commented 4 years ago

I believe you have an older version of SASmarkdown (probably from CRAN) with a newer version of knitr.

Try knitting a document with just

packageVersion(“knitr”)
packageVersion(“SASmarkdown”)

For recent versions of knitr you want SASmarkdown version >=0.5.2.

To install the latest version, do this in R:

remove.packages(“SASmarkdown”)
devtools::install_github(“Hemken/SASmarkdown”)
mgdondon commented 4 years ago

Hello,

I'm using the version from CRAN and it's OK.

I think you should modify the r setup chunk.

Your setup

```{r setup, include=FALSE}

knitr::opts_chunk$set(echo = TRUE)
library(SASmarkdown)

saspath <- "C:/Program Files/SASHome/SASFoundation/9.4/sas.exe"
sasopts <- "-nosplash -ls 75"

knitr::opts_chunk$set(engine.path=list(sas=saspath, saslog=saspath),
                      engine.opts=list(sas=sasopts, saslog=sasopts), 
                      comment=NA)

--> KO

My setup

```{r setup, include=FALSE}

knitr::opts_chunk$set(echo = TRUE)
library(SASmarkdown)

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="")

--> OK

Note also that you have to move up the library call.

Best regards,

gozeErG commented 4 years ago

Dear Doug,

Thank you so much for your quick and precise answer : it works now !

While at it, I updated knitr and SASmarkdown, and it still works !

Again, thank you also for making this package that is going to be very useful to me.

Best regards,

Eric Gozé

De : mgdondon notifications@github.com Envoyé : mercredi 27 novembre 2019 15:06 À : Hemken/SASmarkdown SASmarkdown@noreply.github.com Cc : gozeErG goze@cirad.fr; Author author@noreply.github.com Objet : Re: [Hemken/SASmarkdown] Sas execution stuck, command line seems to be sent twice (#11)

Hello,

I'm using the version from CRAN and it's OK.

I think you should modify the r setup chunk.

Your setup



knitr::opts_chunk$set(echo = TRUE)
library(SASmarkdown)

saspath <- "C:/Program Files/SASHome/SASFoundation/9.4/sas.exe"
sasopts <- "-nosplash -ls 75"

knitr::opts_chunk$set(engine.path=list(sas=saspath, saslog=saspath),
                      engine.opts=list(sas=sasopts, saslog=sasopts),
                      comment=NA)

--> KO

My setup

```{r setup, include=FALSE}

knitr::opts_chunk$set(echo = TRUE)
library(SASmarkdown)

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="")

--> OK

Note also that you have to move up the library call.

Best regards,

—
You are receiving this because you authored the thread.
Reply to this email directly, 
<https://github.com/Hemken/SASmarkdown/issues/11?email_source=notifications&email_token=AN4OOOTKZMBRVOJGP73MYE3QVZ5DTA5CNFSM4JSE5IQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFJTIIY#issuecomment-559100963> 
view it on GitHub, or 
<https://github.com/notifications/unsubscribe-auth/AN4OOOVPKBY5IPKZBQLKJK3QVZ5DTANCNFSM4JSE5IQQ> 
unsubscribe.
Hemken commented 4 years ago

Hello,

I'm using the version from CRAN and it's OK.

I think you should modify the r setup chunk.

My setup

knitr::opts_chunk$set(echo = TRUE) library(SASmarkdown)

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="")



--> OK

Note also that you have to move up the library call.

Best regards,

While this works for older SASmarkdown, you lose the debugging capability of automatically switching to the saslog engine if your SAS produces an ERROR message.

Hemken commented 4 years ago

Also, either position for the library call should work, unless you set an engine="sas" chunk option. You don't actually need to load SASmarkdown until just before a code chunk that evaluates SAS.

More recent versions of knitr, which allow for lists of engines, enable much more graceful switching between languages and engines.

Hemken commented 4 years ago

If you are mainly a SAS programmer, all these details may be too much. Just keep the setup simple and you'll be fine.

gozeErG commented 4 years ago

Dear Doug,

thank you again.

By default, my version of Sas outputs French, with accents encoded in latin1, so that characters such as é or ù appear as hieroglyphs in html output. I switched the sas locale to English by selecting the proper sasv9.cfg with a modified sasopts string :

sasopts <- "-nosplash -ls 75 -CONFIG 'C:\Program Files\SASHome\SASFoundation\9.4\nls\en\sasv9.cfg'"

Now the sas output is fine, because it is free of any accent. My comments in the source are fine also in the html output as long as they are encoded with UTF-8.

Best regards,

Eric

De : Doug Hemken notifications@github.com Envoyé : mercredi 27 novembre 2019 15:37 À : Hemken/SASmarkdown SASmarkdown@noreply.github.com Cc : gozeErG goze@cirad.fr; Author author@noreply.github.com Objet : Re: [Hemken/SASmarkdown] Sas execution stuck, command line seems to be sent twice (#11)

Also, either position for the library call should work, unless you set an engine="sas" chunk option. You don't actually need to load SASmarkdown until just before a code chunk that evaluates SAS.

More recent versions of knitr, which allow for lists of engines, enable much more graceful switching between languages and engines.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Hemken/SASmarkdown/issues/11?email_source=notifications&email_token=AN4OOOTS3SEBT4U2T2J2NGLQV2AZDA5CNFSM4JSE5IQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFJWJLY#issuecomment-559113391 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AN4OOOW2FR7ZN2HRNBLOK7TQV2AZDANCNFSM4JSE5IQQ .

Hemken commented 4 years ago

Encoding is tricky. Both knitr and pandoc (on which knitr relies) expect UTF-8. In SAS, you can usually also find a UTF-8 config. And then, what shows up on your HTML server depends on what is set as the default encoding there.

From: gozeErG [mailto:notifications@github.com] Sent: Wednesday, November 27, 2019 9:48 AM To: Hemken/SASmarkdown Cc: Doug Hemken; State change Subject: Re: [Hemken/SASmarkdown] Sas execution stuck, command line seems to be sent twice (#11)

Dear Doug,

thank you again.

By default, my version of Sas outputs French, with accents encoded in latin1, so that characters such as é or ù appear as hieroglyphs in html output. I switched the sas locale to English by selecting the proper sasv9.cfg with a modified sasopts string :

sasopts <- "-nosplash -ls 75 -CONFIG 'C:\Program Files\SASHome\SASFoundation\9.4\nls\en\sasv9.cfg'"

Now the sas output is fine, because it is free of any accent. My comments in the source are fine also in the html output as long as they are encoded with UTF-8.

Best regards,

Eric

De : Doug Hemken notifications@github.com Envoyé : mercredi 27 novembre 2019 15:37 À : Hemken/SASmarkdown SASmarkdown@noreply.github.com Cc : gozeErG goze@cirad.fr; Author author@noreply.github.com Objet : Re: [Hemken/SASmarkdown] Sas execution stuck, command line seems to be sent twice (#11)

Also, either position for the library call should work, unless you set an engine="sas" chunk option. You don't actually need to load SASmarkdown until just before a code chunk that evaluates SAS.

More recent versions of knitr, which allow for lists of engines, enable much more graceful switching between languages and engines.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Hemken/SASmarkdown/issues/11?email_source=notifications&email_token=AN4OOOTS3SEBT4U2T2J2NGLQV2AZDA5CNFSM4JSE5IQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFJWJLY#issuecomment-559113391 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AN4OOOW2FR7ZN2HRNBLOK7TQV2AZDANCNFSM4JSE5IQQ .

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/Hemken/SASmarkdown/issues/11?email_source=notifications&email_token=ACYBMEZ4J3V7IFUI45YOOLLQV2CB5A5CNFSM4JSE5IQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFJXLYA#issuecomment-559117792, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACYBME4NS72BVL2D6LFVCN3QV2CB5ANCNFSM4JSE5IQQ.

mgdondon commented 4 years ago

While this works for older SASmarkdown, you lose the debugging capability of automatically switching to the saslog engine if your SAS produces an ERROR message.

Thank you for the information (related to #6).

Best regards,