sas - 如何在 SortedBy 字段中显示来自 PROC CONTENTS 的排序方法?
问题描述
我试图表明我的数据已在我的 PROC 内容输出中排序。在此输出中有一个名为“SortedBy”的属性,其中显示了内容的排序方式(据我所知)。
我的问题是,我怎样才能让我的输出如下所示:
这是我的代码:
/*Not sorted*/
proc contents data = I.projects;
run;
/*Sorted*/
proc sort data = WORK.projects out = projects;
by REGION descending POL NAME;
run;
proc contents data = WORK.projects;
run;
解决方案
选择SORTEDBY
输出表;正如@Bill 提到的先前提交ODS TRACE ON
将列出输出表。
proc sort data=sashelp.cars out=cars;
by descending make model type;
run;
ods select sortedby;
proc contents data=cars;
run;
跟踪信息出现在 SAS 日志中
67 ods trace on;
68 proc contents data=cars;
69 run;
Output Added:
-------------
Name: Attributes
Label: Attributes
Template: Base.Contents.Attributes
Path: Contents.DataSet.Attributes
-------------
Output Added:
-------------
Name: EngineHost
Label: Engine/Host Information
Template: Base.Contents.EngineHost
Path: Contents.DataSet.EngineHost
-------------
Output Added:
-------------
Name: Variables
Label: Variables
Template: Base.Contents.Variables
Path: Contents.DataSet.Variables
-------------
Output Added:
-------------
Name: Sortedby
Label: Sortedby
Template: Base.Contents.Sortedby
Path: Contents.DataSet.Sortedby
-------------
NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.05 seconds
cpu time 0.03 seconds
70 ods trace off;
您还可以SORTEDBY
使用数据步进函数检索数据集属性ATTRC
data before (keep=sortedby);
when = 'BEFORE';
ds = open('cars');
sortedby = attrc(ds,'SORTEDBY');
ds = close (ds);
run;
* sort … ;
data after (keep=sortedby);
when = 'AFTER';
ds = open('cars');
sortedby = attrc(ds,'SORTEDBY');
ds = close (ds);
run;
data compare;
set before after;
run;
推荐阅读
- javascript - 无论您使用什么设备或屏幕尺寸,如何使 svg 高度与屏幕高度匹配
- reactjs - 来自 Postgres 数据库的反应复选框
- javascript - 选择器 " 不匹配任何元素
- runtime-error - 翻转列表中的元组时,方案错误显示“尝试应用非程序”
- javascript - 为什么我在 React 中收到无效的 Hook 调用?
- php - 从特定范围内生成 x 个不重复且不在数组中的随机数
- angular - 亚马逊跨域请求被阻止:
- html - 如何在多个域中托管相同的网站内容
- security - CSRF 令牌是否足以防止 XSSI 攻击?
- firebase - 将 Firebase 数据渲染到 FlatList