BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mmaccora
Obsidian | Level 7
Hi,

In SAS Enterprise Miner, I would like to use R Code with the Open Source Integration Node.

I need to load the DMwR library from R in order to perform SMOTE sampling.

The node runs without error but the library has not been found.

Someone told me that I have to install R on the SAS Server. Do you know how I could install it on the server and then make use of the library ?

Thank you for your help,
Marco
1 ACCEPTED SOLUTION

Accepted Solutions
jemayo
SAS Employee

Hi mmaccora,

 

First let me clarify what the R working directory and workspace mean. The workspace is your current R working environment and includes any user-defined objects (vectors, matrices, data frames, lists, functions). At the end of an R session, the user can save an image of the current workspace to a location on the file system, the "working directory", and it will automatically reload the next time R is started.  SAS Enterprise Miner's Open Source Integration (OSI) node sets the R working directory to a temporary file, just the same as SAS creates a SAS working directory for each SAS session. These are temporary files that disappear after the session ends. If you turn on options mprint in the project start code and rerun the node, you will see where the OSI node sets the working directory:

 

NOTE: %INCLUDE (level 1) file _RSUBMIT is file C:\Users\jemayo\AppData\Local\Temp\SAS Temporary Files\_TD18080_d10a871_\Prc2\RSUBMIT.sas.
24560 +_WORK_DIR= "%sysfunc(getoption(work))";
MPRINT(EM_OPEN_TRAIN): _WORK_DIR= "C:\Users\jemayo\AppData\Local\Temp\SAS Temporary Files\_TD18080_d10a871_\Prc2";

 

We don't recommend changing the work directory, but if you do decide to change it, make sure you have read and write permissions to that location and the location exists.

 

 

 

To answer your original question regarding installation directory and how that works:

In the picture you sent in of the OSI node log, it looks like you are trying to set the working directory for R to tell the OSI node where the libraries are located. You don't need to do this. When you install an R package, the packages install to the location you included in setwd("C:/Program Files/R/R-3.2.5/library"). After they are installed in R, you do not need to point to this location again, even in the OSI node. You simply need to call the library you want to use. The only code you would need to put in the code editor would be: 

 

library(DMwR)

&EMR_EXPORT_TRAIN <- SMOTE(form = &EMR_CLASS_TARGET ~ &EMR_CLASS_INPUT + &EMR_NUM_INPUT, data = &EMR_IMPORT_DATA, perc.over = 200, k = 5, perc.under = 1000)

 

Enterprise Miner passes the code back to R to run, and R already knows where to find these packages. Your code should run successfully without the setwd() command.

 

 

I hope this helps!

Jess Mayo

SAS Technical Support

View solution in original post

6 REPLIES 6
mmaccora
Obsidian | Level 7
Thank you, I already had seen the proposed page. There is no answer to my problem in it.
SASKiwi
PROC Star

Did you check the other links in the note? I found information relating to your questions. Also the EM Reference Manual has some useful stuff in the Open Source Code Node chapter 72:

 

http://support.sas.com/documentation/onlinedoc/miner/em132/emref.pdf

 

mmaccora
Obsidian | Level 7

Yes, thank you for the docs, but I could not find an answer to my problem.

 

I have installed the R library in the root as it is recommended in your documentation. Now, the warning message that the library could not be found disappeared. But now, the problem is that the working directory (macro _WORK_DIR) cannot be changed (see picture of the log).

 

I don't know where is the correct location for installing the library and how to install it. Do you know where and the way to do it ?

 

Thank you,

Marco

 

PS: _WORK_DIR is set to "%sysfunc(getoption(work))"

SASKiwi
PROC Star

I've haven't installed R yet but we are looking at getting it working soon. I think you should track this problem with SAS Tech Support if you haven't done so already.

jemayo
SAS Employee

Hi mmaccora,

 

First let me clarify what the R working directory and workspace mean. The workspace is your current R working environment and includes any user-defined objects (vectors, matrices, data frames, lists, functions). At the end of an R session, the user can save an image of the current workspace to a location on the file system, the "working directory", and it will automatically reload the next time R is started.  SAS Enterprise Miner's Open Source Integration (OSI) node sets the R working directory to a temporary file, just the same as SAS creates a SAS working directory for each SAS session. These are temporary files that disappear after the session ends. If you turn on options mprint in the project start code and rerun the node, you will see where the OSI node sets the working directory:

 

NOTE: %INCLUDE (level 1) file _RSUBMIT is file C:\Users\jemayo\AppData\Local\Temp\SAS Temporary Files\_TD18080_d10a871_\Prc2\RSUBMIT.sas.
24560 +_WORK_DIR= "%sysfunc(getoption(work))";
MPRINT(EM_OPEN_TRAIN): _WORK_DIR= "C:\Users\jemayo\AppData\Local\Temp\SAS Temporary Files\_TD18080_d10a871_\Prc2";

 

We don't recommend changing the work directory, but if you do decide to change it, make sure you have read and write permissions to that location and the location exists.

 

 

 

To answer your original question regarding installation directory and how that works:

In the picture you sent in of the OSI node log, it looks like you are trying to set the working directory for R to tell the OSI node where the libraries are located. You don't need to do this. When you install an R package, the packages install to the location you included in setwd("C:/Program Files/R/R-3.2.5/library"). After they are installed in R, you do not need to point to this location again, even in the OSI node. You simply need to call the library you want to use. The only code you would need to put in the code editor would be: 

 

library(DMwR)

&EMR_EXPORT_TRAIN <- SMOTE(form = &EMR_CLASS_TARGET ~ &EMR_CLASS_INPUT + &EMR_NUM_INPUT, data = &EMR_IMPORT_DATA, perc.over = 200, k = 5, perc.under = 1000)

 

Enterprise Miner passes the code back to R to run, and R already knows where to find these packages. Your code should run successfully without the setwd() command.

 

 

I hope this helps!

Jess Mayo

SAS Technical Support

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 3151 views
  • 4 likes
  • 3 in conversation