Jim Crozier
Jim Crozier

Reputation: 1418

Knitr hanging on system() call

How do I get knitr to un-hang after running a system call in a chunk? For example:

\documentclass{article}

\begin{document}
Test 

<<>>=
system('"C:\\Program Files\\SASHome\\SASFoundation\\9.3\\sas.exe" "test.sas"')
@

\end{document}

This code just hangs forever. By the way, the R code above runs fine. Thanks.

Upvotes: 2

Views: 410

Answers (1)

Yihui Xie
Yihui Xie

Reputation: 30124

By default the working directory for the code chunks is the directory of your source document (Rnw doc in this case), so test.sas has to be under the same directory with the Rnw file.

Or you can specify the working directory for code chunks with opts_knit$set(root.dir = '/path/to/desired/dir/').

SAS support in knitr has been added to the development version, and this is what you can do:

<<engine='sas', engine.path="C:\\Program Files\\SASHome\\SASFoundation\\9.3\\sas.exe">>=
/* write the content of your test.sas here */
@

Upvotes: 3

Related Questions