BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GabACM
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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

2 REPLIES 2
Rick_SAS
SAS Super FREQ

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/

GabACM
Calcite | Level 5

OK, thank you for your answer Rick Wicklin.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Multiple Linear Regression in SAS

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.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 2 replies
  • 1036 views
  • 0 likes
  • 2 in conversation