sas - SAS PROC SQL UNION ALL - 最小化列长度
问题描述
我有 8 个表,所有表都包含相同的顺序和列数,而一个名为 ATTRIBUTE 的特定列包含长度为 4 到 25 的不同数据。当我使用 PROC SQL 和 UNION ALL 表时,ATTRIBUTE 列数据长度最小化为最低(4 位数)。我该如何解决,即保持数据的全长?
解决方案
例如,根据@Lee
data have1;
attrib name length=$10 format=$10.;
name = "Anton Short";
run;
data have2;
attrib name length=$50 format=$50.;
name = "Pippy Longstocking of Stoyville";
run;
* column attributes such as format, informat and label of the selected columns
* in the result set are 'inherited' on a first found first kept order, dependent on
* the SQL join plan (i.e. the order of the tables as coded for the query);
proc sql;
create table want as
select name from have1 union
select name from have2
;
proc contents data=want varnum;
run;
Format 比 Length 短,任何较长值的输出显示都将在数据级别被截断。
* attributes of columns can be reset,
* (cleared so as to be dealt with in default manners),
* without rewriting the entire data set;
proc datasets nolist lib=work;
modify want;
attrib name format=; * format= removes the format of a variable;
run;
proc contents data=want varnum;
run;
推荐阅读
- javascript - 如何实现我的 jQuery 代码以在我的网站上工作?
- javascript - Konva 中的平行线分隔符
- javascript - 在 React Child 中访问 Props 以映射数组?
- c++ - 在 C++17 中实现迭代器和 const_iterator 的正确方法是什么?
- python - 仅在重新启动 gunicorn 后才会显示对数据库的更改
- c - 如何对两个 32Q16 定点整数进行除法?
- extjs - 如何消除行的小计,但将总计留在 sencha 数据透视表上?
- c - 我应该使用 GetFileSize 还是 _stat64 在 Windows 上获取文件大小?
- python - 如何在烧瓶中返回数据类型(对象)
- python - Python / pymeep / ModuleNotFoundError:没有名为“pymeep”的模块