Manohar Swamynathan
Manohar Swamynathan

Reputation: 2095

Error with %PROC_R: A SAS Macro that Enables Native R Programming in the Base SAS Environment

Since R and SAS are here to stay in statistical analysis world, I'have been exploring what ways exists to make them work better with each other. Downloaded $PROC_R from URL- http://www.jstatsoft.org/v46/c02, which is a SAS macro that enable running R code in base SAS environment. Also followed the instruction from the supplements PDF file to create a modified SAS shortcut on desktop as I'm using SAS 9.4 in Windows 8 OS.

When I execute the example code I get 2 errors.

SAS Code:

data test;
do x=1 to 4;
array a[4] a1-a4;
do i=1 to 4;
a[i] = rannor(100);
end;
output;
end;
drop i x;
run;

%include "C:\Proc_R.sas";
%Proc_R (SAS2R = test, R2SAS =);
cards4;
R> testm <- as.matrix(test)
R> eigen(testm)
;;;;
%quit;

1st Error: (however the code execution does not halt here)

ERROR: Physical file does not exist, C:\Users\878572\AppData\Local\Temp\SAS Temporary
   Files\_TD4972_01HW475399_\r_log_1737015649.txt.

2nd Error:

ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric
   operand is required. The condition was: &fgsw=1
ERROR: The macro QUIT will stop executing.

Appreciate any help.

Upvotes: 0

Views: 1042

Answers (2)

burton030
burton030

Reputation: 405

I had the same problem. I did not solve it till now but I circumvent this problem by deleteing the passage in the macro which is about "display R graphics" (line 181 till 233 in the macro). After doing this it worked for me. I will do some further investigations. I read here

http://saslist.com/blog/category/proc_r/

sth. about a setwd() statement to fix problems with graphics.

Hope it helps for the moment. I will give a new answer if I found any solution...

All in all I think it's a great macro but unfortunately there is not much literature about it.

Cheers

Upvotes: 0

Reeza
Reeza

Reputation: 21294

The code is approximately 4 years old, it will need some modifications to run on your system.

https://github.com/Jiangtang/Programming-SAS/blob/master/Proc_R.sas

For starters:

Change Line 49 to reference your version of R, most likely R version 3 something.

I haven't tested the rest of the code so you may run into more errors.

Upvotes: 1

Related Questions