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

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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
  • 865 views
  • 0 likes
  • 2 in conversation