如何使用模板从sas导出到excel

时间:2016-12-06 13:36:22

标签: excel sas export-to-excel

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.5.1        0.0.0.0         UG    0      0        0 eth1
1.0.0.0         10.0.12.2       255.255.255.0   UG    0      0        0 eth0
1.0.1.0         10.0.5.1        255.255.255.0   UG    0      0        0 eth1
10.0.1.0        10.0.12.2       255.255.255.0   UG    0      0        0 eth0
10.0.2.0        10.0.5.1        255.255.255.0   U     1      0       0 eth1
10.0.5.0        0.0.0.0         255.255.255.0   U     1      0        0 eth1
10.0.12.0       0.0.0.0         255.255.255.0   U     1      0        0 eth0

SAS中的简单proc导出代码。但是,我想使用“template_SASdata.xlsx”文件作为模板,并将我的数据保存在一个全新的文件中,该文件与我原来的excel模板相同,但更新了“输入”表。

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth4
1.0.0.0         10.0.11.2       255.255.255.0   UG    0      0        0 eth0
1.0.1.0         10.0.13.1       255.255.255.0   UG    0      0        0 eth1
10.0.1.0        10.0.11.2       255.255.255.0   UG    0      0        0 eth0
10.0.2.0        10.0.13.1       255.255.255.0   UG    0      0        0 eth1
10.0.11.0       0.0.0.0         255.255.255.0   U     1      0        0 eth0
10.0.13.0       0.0.0.0         255.255.255.0   U     1      0        0 eth1
192.168.0.0     0.0.0.0         255.255.255.0   U     1      0        0 eth4

如何在我的proc导出中包含它? 我试图添加

proc export data=data1
    OUTFILE="place_on_pc\template_SASdata.xlsx"
    DBMS=EXCEL REPLACE;
    sheet=input;  
run;

在我的proc导出中,但这不起作用。

1 个答案:

答案 0 :(得分:1)

您需要先将原始文件复制到新文件,然后导出以替换要添加数据的工作表。

或者,我使用并喜欢的方法,您可以导出到与模板无关的文件,然后在您运行的模板中有一个VBA宏,您可以识别数据表并且宏打开数据表,对数据执行任何操作,并在最后保存新文件。我喜欢这个,如果你要做任何其他格式化,因为excel有相当好的工具,你在这里做的。如果您没有进行任何其他格式化,那么请让SAS复制该文件(假设您可以在您的环境中使用x命令)。

x 'copy [template file] [new file]'