简体   繁体   English

通过R传递解析的SAS宏变量

[英]Passing a resolved SAS macro variable through R

I'm generating a PDF that goes through quite a journey. 我正在生成一个相当长的旅程的PDF。 First, a SAS macro creates a .txt file which is read into R, which is then output into a final PDF. 首先,SAS宏创建一个.txt文件,该文件被读入R,然后输出到最终的PDF中。 I would like to run my R program through SAS, but I need to pass a filepath referenced in SAS to R. I've looked into using the 'rawr' package, but this isn't passing resolved SAS macro variables through R. Any insight would be greatly appreciated. 我想通过SAS运行我的R程序,但我需要将SAS中引用的文件路径传递给R。我已经研究过使用“原始”包,但这并不是通过R传递解析的 SAS宏变量。有识之士将不胜感激。 I'd explore any avenue. 我会探索任何途径。 Thanks! 谢谢!

As Quentin says, you can pass information from SAS to R by using the SAS/IML interface. 正如Quentin所说,您可以使用SAS / IML接口将信息从SAS传递到R。 On the SUBMIT line you can put any SAS/IML variable and that value of that variable will be substituted (as text) into the SAS program before SAS sends the program to R. The SAS/IML documentation contains examples. 在SUBMIT行上,您可以放置​​任何SAS / IML变量,并且在SAS将程序发送到R之前,该变量的值将被替换(作为文本)到SAS程序中。SAS / IML文档包含示例。

If you want to send a macro value into R, first store it into a SAS/IML variable, then pass the value of the SAS/IML variable to R, as follows: 如果要将宏值发送到R,请首先将其存储到SAS / IML变量中, 然后将SAS / IML变量的值传递给R,如下所示:

%let path = C:/Temp/Path1;
proc iml;
path1 = "&path";   /* copy to character string */
submit path1 / R; 
    theSASpath <- "&path1"
    theSASpath
endsubmit;

If the value of the macro variable changes while the program is running, just rerun the "path = " and SUBMIT statements to update the R copy of the path. 如果程序运行时宏变量的值发生变化,只需重新运行“ path =”和SUBMIT语句即可更新路径的R副本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM