Statistical programming, matrix languages, and more

Keep R opened

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Keep R opened

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.


Accepted Solutions
Solution
‎12-10-2013 09:01 AM
SAS Super FREQ
Posts: 3,420

Re: Keep R opened

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/

View solution in original post


All Replies
Solution
‎12-10-2013 09:01 AM
SAS Super FREQ
Posts: 3,420

Re: Keep R opened

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/

New Contributor
Posts: 4

Re: Keep R opened

OK, thank you for your answer Rick Wicklin.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 355 views
  • 0 likes
  • 2 in conversation