在某些情况下,我需要在SAS中运行一个过程,然后保存输出变量以供另一个程序(MATLAB)访问。这很简单,例如:
proc genmod order=data;
class X Y Z;
output out= gmout1 prob = PRED;
model count=X Y Z /dist=poi pred;
run; *mutual independence;
proc export data = work.gmout1
outfile = "...\genmodout1.txt"
dbms = csv replace;
run;
第三行中的output out= gmout1
将proc genmod导出的所有变量保存到一个名为gmout1的库表中。
我目前的需求是能够访问存储在SAS本身内的gmout1中的一些数据。应该很简单,但我的搜索没有找到任何有用的东西。
发布于 2013-02-21 07:10:29
可以使用data
选项将数据集gmout1用作其他procs的输入。例如,如果要打印以下内容:
proc print data=gmout1;
var _all_;
run;
您还可以使用set
语句通过data步骤( SAS中的大多数编程都发生在这里)对数据进行修改。例如,如果您有一个变量"fit“,并且需要将其重新编码为x100,您可以这样做:
data gmout2; *creates new dataset gmout2;
set gmout1; *use the dataset gmout1;
new_fit = fit * 100;*creates new variable new_fit as 100 times fit;
run;
要将特定变量(或多个变量)导出到文本文件,您有多种选择。最简单的:
data _null_;
set gmout1;
file "c:\temp\myfile.csv" dlm=',' lrecl=32767 dsd;
if dimension="Value" and dimension2="Value";
put
variable1_numeric
variable2_character $
variable3_numeric
;
run;
我注意到你提到过,基于矩阵技术的SAS不能操作矩阵,只能操作数据集(基本上是数据行)。SAS/IML是矩阵语言;它的用法类似于R,并且允许通用的矩阵语法。
https://stackoverflow.com/questions/14996190
复制