表示“PUT所有变量”在数据步骤中导出SAS数据 [英] Express "PUT all variables" in a data step to export SAS data

查看:725
本文介绍了表示“PUT所有变量”在数据步骤中导出SAS数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:使用数据步骤将整个SAS数据集导出到制表符分隔的文本文件。

Goal: export an entire SAS dataset to a tab-delimited text file using a data step.

问题:在每个可以找到的例子中,例如这一个,必须在PUT语句之后的数据步骤中指定每个变量。

Problem: In every example that I can find, such as this one, one must specify every variable in the data step following the PUT statement. Isn't there a simple method to just ask for "all" of the variables?

我已经尝试使用 PUT _ALL _ ,但是在输出的每一行中都包含变量名称,而不是仅输出值。

I have already tried using PUT _ALL_, but that includes the variable names in every row of the output, instead of just outputtin the values.

推荐答案

如果要在数据步骤中执行此操作,并且不想指定事物,但实际上不希望 PROC EXPORT 作出决定你,并且有相当容易指定的数据(没有什么像你想要的特殊格式的日期),你可以这样做。

If you want to do it in a data step, AND don't want to specify things, but really don't want PROC EXPORT making decisions for you, AND have data that's reasonably easily specified (nothing fancy like dates you want in a special format), you can do this.

proc sql;
select name into :namelist separated by ' ' 
from dictionary.columns
where libname='SASHELP' and memname='CLASS'; *these are the libname/dataset name you want;
quit; 

filename blah temp;
data _null_;
set sashelp.class;
file blah dlm='09'x;
put &namelist.;
run;

您可以通过修改sql查询(例如,如果您有您可以在sql查询中修改 _date 的变量集,以添加 name ||':date9。对于那些。

You can customize it some depending on your needs by modifying the sql query (such as if you have a set of variables with _date perhaps you could modify it to add name||' :date9.' in the sql query for those.

请注意,dictionary.columns中的libname / memname / name字段通常是大写字母,它们不是总是我不认为,但他们几乎总是(有些RDBMS例如可以覆盖这个,我相信)。

Note that the libname/memname/name fields in dictionary.columns are typically upper case. They are not always upper case, I don't think, but they almost always are. (Some RDBMSs for example can override this, I believe).

这篇关于表示“PUT所有变量”在数据步骤中导出SAS数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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