Hello everyone,
I'm trying to pass SAS datasets to R and leave the R window open once the data is transfered.
Indeed the typical use is:
proc iml;
call ExportDataSetToR("myData","data");
submit /R;
#### code
endsubmit;
The problem with this is that the R windows is neither opened nor closed. We just see the outcome of the R code within the SAS Results page.
I would be interested in interacting further with the data transfered to R within R directly.
Is there a way to keep the R window opened ?
Thank you in advance.
The SUBMIT / R statement enables you to submit R statements that you have already developed and debugged in an R session. It does not create an R session with a program console for you to interactively work on a program.
However, when you use the SAS/IML interface, R does not go away after the ENDSUBMIT statement, so a certain degree of interaction is possible. For example, see the first item/example on the list in this article: Twelve advantages to calling R from the SAS/IML language - The DO Loop
Other interactions are also possible. For example, run the following program and follow its directions:
proc iml;
run ExportDataSetToR("Sashelp.cars", "cars");
submit / R;
plot( cars$MPG_City, cars$MPG_Highway )
print ("Click on markers where MPG_City>40")
print ("Then right-click and select 'Stop'")
sel <- identify(cars$MPG_City, cars$MPG_Highway)
endsubmit;
/* retrieve obs numbers of selected obs and print in PROC IML */
run ImportMatrixFromR(selList, "sel");
use Sashelp.Cars;
read all var {Make Model};
close Sashelp.Cars;
print (Make[selList]||Model[selList])[L="The Selected Cars"];
http://blogs.sas.com/content/iml/2013/11/25/twelve-advantages-to-calling-r-from-the-sasiml-language/
The SUBMIT / R statement enables you to submit R statements that you have already developed and debugged in an R session. It does not create an R session with a program console for you to interactively work on a program.
However, when you use the SAS/IML interface, R does not go away after the ENDSUBMIT statement, so a certain degree of interaction is possible. For example, see the first item/example on the list in this article: Twelve advantages to calling R from the SAS/IML language - The DO Loop
Other interactions are also possible. For example, run the following program and follow its directions:
proc iml;
run ExportDataSetToR("Sashelp.cars", "cars");
submit / R;
plot( cars$MPG_City, cars$MPG_Highway )
print ("Click on markers where MPG_City>40")
print ("Then right-click and select 'Stop'")
sel <- identify(cars$MPG_City, cars$MPG_Highway)
endsubmit;
/* retrieve obs numbers of selected obs and print in PROC IML */
run ImportMatrixFromR(selList, "sel");
use Sashelp.Cars;
read all var {Make Model};
close Sashelp.Cars;
print (Make[selList]||Model[selList])[L="The Selected Cars"];
http://blogs.sas.com/content/iml/2013/11/25/twelve-advantages-to-calling-r-from-the-sasiml-language/
OK, thank you for your answer Rick Wicklin.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.