Closed srvanderplas closed 2 years ago
Susan , it may be that I included a “minimal” style declaration in the header of the SAS file used to generate output. In that case, you just need to include a style declaration explicitly in your code block (or in a previous code block if you are using collectcode).
From: Susan VanderPlas notifications@github.com Sent: Thursday, October 1, 2020 11:23 AM To: Hemken/SASmarkdown SASmarkdown@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [Hemken/SASmarkdown] Black and White graphics output using SASmarkdown but not SAS in batch mode? (#14)
I'm having trouble figuring out exactly why SASmarkdown is generating all black-and-white figures, when the same code works in batch mode to generate color figures.
I'm working on Ubuntu 18.04, with SAS 9.4.
Here's some code to demonstrate the issue:
indoc <- '
title: reprex
output: html_document
library(SASmarkdown)
sas_enginesetup()
writeLines(c(
"PROC SGPLOT data=sashelp.snacks;",
"SCATTER x = date y = QtySold /",
" markerattrs=(size=8pt symbol=circlefilled)",
" group = product; /* maps to point color by default */",
"RUN;",
"QUIT;"
), con = "reprex.sas")
%include "reprex.sas";
system("sas reprex.sas")
'
knitr::knit(text=indoc, output="test.md")
rmarkdown::render("test.md")
Which looks like this when rendered:
[image]https://user-images.githubusercontent.com/2127125/94835537-71618300-03d7-11eb-9c5b-1a62bd671ab8.png
As you can see, the SAS code chunk produces a black-and-white graph, while the batch output renders a graph which is produced in color. Actual graph files generated
[as-in-book]https://user-images.githubusercontent.com/2127125/94836056-21cf8700-03d8-11eb-8a74-7f3aa4c19ca1.png
[SGPlot]https://user-images.githubusercontent.com/2127125/94836129-3c096500-03d8-11eb-8969-04ed8cc3fc03.png
I don't know SAS that well, so I'm open to the possibility that there is just an obvious option that I'm missing here, but if that's the case, why does batch mode produce color graphs while SASmarkdown produces black-and-white graphs?
Thanks for the help.
Cleanup: You can remove the files generated by this reprex from your machine using file.remove(c("SGPlot.png","as-in-book.png", "test.md", "test.html")) in R.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Hemken/SASmarkdown/issues/14, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACYBME7VFMGZKUHY7ST2MT3SISUE7ANCNFSM4SAUTKUA.
Yep, that did it, thanks!
It might be worth reconsidering the "minimal" option if only so that the default behavior is the same in SAS and SASmarkdown.
For anyone else who comes across this and doesn't know exactly what a style declaration would look like (because I didn't, not being a particularly experienced SAS user), this worked for me:
indoc <- '
---
title: reprex
output: html_document
---
```{r load-sas-libraries, echo =T, message = F, warning = F}
library(SASmarkdown)
sas_enginesetup()
writeLines(c(
"ODS HTML style=htmlblue;",
"PROC SGPLOT data=sashelp.snacks;",
"SCATTER x = date y = QtySold /",
" markerattrs=(size=8pt symbol=circlefilled)",
" group = product; /* maps to point color by default */",
"RUN;",
"QUIT;"
), con = "reprex.sas")
%include "reprex.sas";
system("sas reprex.sas")
' knitr::knit(text=indoc, output="test.md") rmarkdown::render("test.md")
Thanks for providing the example code.
If others find this annoying, please let me know. I could consider turning this into a chunk option, I suppose.
From: Susan VanderPlas notifications@github.com Sent: Friday, October 2, 2020 7:02 PM To: Hemken/SASmarkdown SASmarkdown@noreply.github.com Cc: Doug Hemken dehemken@wisc.edu; Comment comment@noreply.github.com Subject: Re: [Hemken/SASmarkdown] Black and White graphics output using SASmarkdown but not SAS in batch mode? (#14)
Yep, that did it, thanks!
It might be worth reconsidering the "minimal" option if only so that the default behavior is the same in SAS and SASmarkdown.
For anyone else who comes across this and doesn't know exactly what a style declaration would look like (because I didn't, not being a particularly experienced SAS user), this worked for me:
indoc <- '
title: reprex
output: html_document
library(SASmarkdown)
sas_enginesetup()
writeLines(c(
"ODS HTML style=htmlblue;",
"PROC SGPLOT data=sashelp.snacks;",
"SCATTER x = date y = QtySold /",
" markerattrs=(size=8pt symbol=circlefilled)",
" group = product; /* maps to point color by default */",
"RUN;",
"QUIT;"
), con = "reprex.sas")
%include "reprex.sas";
system("sas reprex.sas")
'
knitr::knit(text=indoc, output="test.md")
rmarkdown::render("test.md")
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/Hemken/SASmarkdown/issues/14#issuecomment-703006716, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACYBME7CTJODSGFMS7HFJQTSIZSXPANCNFSM4SAUTKUA.
A chunk option sounds like an excellent way to handle it!
For now this remains a SAS option, not a knitr option. See SASmarkdown docs
I'm having trouble figuring out exactly why SASmarkdown is generating all black-and-white figures, when the same code works in batch mode to generate color figures.
I'm working on Ubuntu 18.04, with SAS 9.4.
Here's some code to demonstrate the issue:
' knitr::knit(text=indoc, output="test.md") rmarkdown::render("test.md")