将 sas 数据集导出到 excel 命名范围 [英] Exporting sas dataset to excel named ranges

查看:50
本文介绍了将 sas 数据集导出到 excel 命名范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 SAS 中的数据集很少.它们将在某些位置导出为 excel 文件.每个数据集要导出到某个范围(命名范围在该 excel 中定义).是否有可能将现有 excel 文件中预定义的特定命名范围"的数据集导出到 excel 中.

I have few datasets in SAS. They are to be exported to a excel file in some locations. Each dataset to be exported to some range(named ranges are defined in that excel). Is there any possibility to export datasets into excel for a specific "named ranges" which are predefined in existing excel file.

谢谢,拉维

推荐答案

如果您有 SAS/ACCESS to Excel,有一个直接导出到 Excel 命名范围的解决方案.对于此示例,假设您在 SAS 环境中安装了 Office,Excel 文件存储在 C:\Data 中,并且您有一个名为 Named_Range 的命名区域.

There is a solution to export directly to an Excel named range provided you have SAS/ACCESS to Excel. For this example, assume that you have Office installed in your SAS environment, the Excel file is stored in C:\Data, and you have a named range called Named_Range.

首先,您要使用 libname 引擎连接到 Excel 数据集:

First, you want to make a connection to the Excel data set using the libname engine:

libname xls Excel 'C:\Data\Excel_Data.xlsx';

然后您可以像数据集一样直接输出到命名范围.如果里面已经有内容,请务必先使用PROC DATASETS删除它们.

You can then output directly to the named range like a data set. If there are contents already in it, be sure to delete them first using PROC DATASETS.

proc datasets lib=xls nolist;
    delete Named_Range;
quit;

data xls.Named_Range;
    set have;
run;

这只是使用它的一个例子,但 libname 引擎的伟大之处在于它如何获取外部数据集并让您像对待 SAS 数据集一样对待它们.如果您的命名范围具有正确的维度,理论上您可以使用任何可以生成数据集的程序直接输出到它.

This is just one example of using it, but the thing that's so great about the libname engine is how it takes external data sets and lets you treat them like SAS data sets. If your named range had the right dimensions, you could theoretically output directly to it using any procedure that can produce a data set.

如果您没有 SAS/ACCESS to Excel,我不确定特定于命名范围的解决方案,尽管您可以使用 PROC EXPORT<中的 RANGE= 选项解决它/code> 与 xls/xlsx dbms 类型.

If you do not have SAS/ACCESS to Excel, I am unsure of a solution specifically with named ranges, though you could work around it using the RANGE= option in PROC EXPORT with the xls/xlsx dbms type.

来源

  1. http://www.stratia.ca/papers/excel_libname.pdf
  2. http://support.sas.com/documentation/cdl/en/acpcref/63181/HTML/default/viewer.htm#n1wvmggexroxgyn17rp61jml3cvn.htm

这篇关于将 sas 数据集导出到 excel 命名范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆