<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Run R code inside SAS easily in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Run-R-code-inside-SAS-easily/m-p/332762#M74940</link>
    <description>&lt;P&gt;Sorry for the confusion, should have added more details. I used MPRINT, and the text files (which you asked) were&amp;nbsp;not found in the work directory assigned by setwd() statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code basically hangs and only way out is Cancel Submitted Statements. &amp;nbsp;I attached the code with few %put inserted. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since the previous attempt of attaching the log file did not go through for some reason, below&amp;nbsp;is the log. &amp;nbsp;Many thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;251 %include "C:\EA_test\Proc_R.sas";&lt;BR /&gt;501&lt;BR /&gt;502 data example;&lt;BR /&gt;503 input Srl x1-x5;&lt;BR /&gt;504 cards;&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.EXAMPLE has 3 observations and 6 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;508 ;&lt;BR /&gt;509 run;&lt;BR /&gt;510 %put "HI 001";&lt;BR /&gt;"HI 001"&lt;BR /&gt;511&lt;BR /&gt;512 /*Run Summary Statistics*/&lt;BR /&gt;513 %Proc_R(SAS2R=example,R2SAS=);&lt;BR /&gt;MPRINT(PROC_R): options notes;&lt;BR /&gt;MPRINT(PROC_R): data _null_;&lt;BR /&gt;MPRINT(PROC_R): call symput('r_code','r_code'||trim(left(scan(put(datetime(),best.),1,'.'))));&lt;BR /&gt;MPRINT(PROC_R): run;&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;r_code1802690920&lt;BR /&gt;MPRINT(PROC_R): data _null_;&lt;BR /&gt;MPRINT(PROC_R): file "C:\Users\TEF419~1\AppData\Local\Temp\SAS Temporary&lt;BR /&gt;Files\_TD2256_WINDOWS7STATIC2_\r_code1802690920.r";&lt;BR /&gt;MPRINT(PROC_R): infile cards4;&lt;BR /&gt;MPRINT(PROC_R): input;&lt;BR /&gt;MPRINT(PROC_R): put _infile_;&lt;BR /&gt;"CHK-00"&lt;BR /&gt;514 cards4;&lt;/P&gt;&lt;P&gt;NOTE: The file "C:\Users\TEF419~1\AppData\Local\Temp\SAS Temporary&lt;BR /&gt;Files\_TD2256_WINDOWS7STATIC2_\r_code1802690920.r" is:&lt;/P&gt;&lt;P&gt;Filename=C:\Users\TEF419~1\AppData\Local\Temp\SAS Temporary&lt;BR /&gt;Files\_TD2256_WINDOWS7STATIC2_\r_code1802690920.r,&lt;BR /&gt;RECFM=V,LRECL=32767,File Size (bytes)=0,&lt;BR /&gt;Last Modified=14Feb2017:11:28:40,&lt;BR /&gt;Create Time=14Feb2017:11:28:40&lt;/P&gt;&lt;P&gt;NOTE: The DATA step has been abnormally terminated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Feb 2017 18:53:35 GMT</pubDate>
    <dc:creator>ea22</dc:creator>
    <dc:date>2017-02-14T18:53:35Z</dc:date>
    <item>
      <title>Run R code inside SAS easily</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-R-code-inside-SAS-easily/m-p/332388#M74807</link>
      <description>&lt;P&gt;Thank you ALL for your feedback.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another try --- I am trying to run the following code (from Listen Data site). &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both SAS and R are on server and windows verstion (instead of SAS UE on server and R on local machine).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;setwd() below does not seem to work, &lt;U&gt;nor&lt;/U&gt;&amp;nbsp;running R code from SAS. &amp;nbsp;Any suggestions!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see rpath in Proc_R.sas (attached) -- which came from a JSS paper. Inside Proc_R, as suggested, I used rpath=%str(C:\Progra~1\R\R-3.3.2\bin\R.exe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%include "C:\test\Proc_R.sas";&amp;nbsp;&lt;/P&gt;&lt;P&gt;data example;&lt;BR /&gt;input Srl x1-x5;&lt;BR /&gt;cards;&lt;BR /&gt;1 . 89 85 . 87&lt;BR /&gt;2 79 73 74 . .&lt;BR /&gt;3 80 82 . 85 .&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;************* EXAMPLE 1 *************;&lt;BR /&gt;/*Run Summary Statistics*/&lt;BR /&gt;%Proc_R(SAS2R=example, R2SAS=);&lt;BR /&gt;cards4;&lt;BR /&gt;setwd("C:/test")&lt;BR /&gt;summary(example)&lt;BR /&gt;;;;;&lt;BR /&gt;%quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc print data=rlog;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 22:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-R-code-inside-SAS-easily/m-p/332388#M74807</guid>
      <dc:creator>ea22</dc:creator>
      <dc:date>2017-02-13T22:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Run R code inside SAS easily</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-R-code-inside-SAS-easily/m-p/332395#M74813</link>
      <description>&lt;P&gt;When you say "below does not seem to work" please describe how it doesn't work. Do you get errors or unexpected warning? Post the code with the log that shows the messages. If inside a macro, run the code with OPTIONS MPRINT; turned on. Post the result in a code box using the {i} icon to keep the forum from re-formatting the text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you get unexpected output describe the expected result and show the actual result.&lt;/P&gt;
&lt;P&gt;Nothing?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you open the generated text file with what I think is supposed to be R code and verify the code written there was as intended?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 22:50:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-R-code-inside-SAS-easily/m-p/332395#M74813</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-13T22:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Run R code inside SAS easily</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-R-code-inside-SAS-easily/m-p/332762#M74940</link>
      <description>&lt;P&gt;Sorry for the confusion, should have added more details. I used MPRINT, and the text files (which you asked) were&amp;nbsp;not found in the work directory assigned by setwd() statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code basically hangs and only way out is Cancel Submitted Statements. &amp;nbsp;I attached the code with few %put inserted. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since the previous attempt of attaching the log file did not go through for some reason, below&amp;nbsp;is the log. &amp;nbsp;Many thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;251 %include "C:\EA_test\Proc_R.sas";&lt;BR /&gt;501&lt;BR /&gt;502 data example;&lt;BR /&gt;503 input Srl x1-x5;&lt;BR /&gt;504 cards;&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.EXAMPLE has 3 observations and 6 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;508 ;&lt;BR /&gt;509 run;&lt;BR /&gt;510 %put "HI 001";&lt;BR /&gt;"HI 001"&lt;BR /&gt;511&lt;BR /&gt;512 /*Run Summary Statistics*/&lt;BR /&gt;513 %Proc_R(SAS2R=example,R2SAS=);&lt;BR /&gt;MPRINT(PROC_R): options notes;&lt;BR /&gt;MPRINT(PROC_R): data _null_;&lt;BR /&gt;MPRINT(PROC_R): call symput('r_code','r_code'||trim(left(scan(put(datetime(),best.),1,'.'))));&lt;BR /&gt;MPRINT(PROC_R): run;&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;r_code1802690920&lt;BR /&gt;MPRINT(PROC_R): data _null_;&lt;BR /&gt;MPRINT(PROC_R): file "C:\Users\TEF419~1\AppData\Local\Temp\SAS Temporary&lt;BR /&gt;Files\_TD2256_WINDOWS7STATIC2_\r_code1802690920.r";&lt;BR /&gt;MPRINT(PROC_R): infile cards4;&lt;BR /&gt;MPRINT(PROC_R): input;&lt;BR /&gt;MPRINT(PROC_R): put _infile_;&lt;BR /&gt;"CHK-00"&lt;BR /&gt;514 cards4;&lt;/P&gt;&lt;P&gt;NOTE: The file "C:\Users\TEF419~1\AppData\Local\Temp\SAS Temporary&lt;BR /&gt;Files\_TD2256_WINDOWS7STATIC2_\r_code1802690920.r" is:&lt;/P&gt;&lt;P&gt;Filename=C:\Users\TEF419~1\AppData\Local\Temp\SAS Temporary&lt;BR /&gt;Files\_TD2256_WINDOWS7STATIC2_\r_code1802690920.r,&lt;BR /&gt;RECFM=V,LRECL=32767,File Size (bytes)=0,&lt;BR /&gt;Last Modified=14Feb2017:11:28:40,&lt;BR /&gt;Create Time=14Feb2017:11:28:40&lt;/P&gt;&lt;P&gt;NOTE: The DATA step has been abnormally terminated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 18:53:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-R-code-inside-SAS-easily/m-p/332762#M74940</guid>
      <dc:creator>ea22</dc:creator>
      <dc:date>2017-02-14T18:53:35Z</dc:date>
    </item>
  </channel>
</rss>

