在 SAS 中重新排序列的最有效方法

编程入门 行业动态 更新时间:2024-10-28 18:26:32
本文介绍了在 SAS 中重新排序列的最有效方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个包含变量 A1、A2、... Amax 的数据 temp.我想重新排列它的内部顺序,这样一旦我们打开它,它就会显示 A2、A5、.....

I have a data temp that contains variables A1, A2, ... Amax. I want to rearrange its internal order so that once we open it, it will show A2, A5, .....

我知道有几种方法可以做到这一点.我通常是使用 retain 语句.

I know there's couple of ways to do this. What I usually to is to use retain statement.

如果观察次数很大(N>1,000,000),那么完成此操作的最有效方法是什么?带有 retain 或 proc sql 或其他东西的数据步骤?

If the number of observation is large (N>1,000,000), what's the most efficient way to finish this? A data step with retain or proc sql or something else?

对我来说,最高效意味着最少的处理时间.如果您还可以提供每种方法所需的内存和磁盘空间的分析,我将不胜感激.

The most efficient means the least processing time for me. I will appreciate if you can also provide the analysis of the memory and disk space needed for each method.

推荐答案

几年前,我在他们位于英国的一个主要办事处参加了 SAS 会议.他们举办了一个与您的问题非常相似的研讨会,他们研究了重新排序和合并/连接数据集的不同技术的速度.

A couple of years ago I attended a SAS conference at one of their main offices in the UK. They held a workshop very similar to your question where they looked into the speed of different techniques of reordering and merging/joining datasets.

SAS 提出的 3 种方式:

The 3 ways which SAS presented where:

  • 传统数据步(保留)

Proc SQL(创建表)

哈希表(特别是在合并表时不一定要重新排序)

有趣的结果是,除非您谈论的是一个非常大的数据集,否则保留表和创建表是均匀匹配的.

The interesting outcome was that unless you're talking about a very large dataset the retain and create table were evenly matched.

显然,如果您想合并/加入和重新排序,那么 proc sql 是一种方法,因为使用数据步骤进行合并需要您先进行排序,而 proc sql 则不需要.如果它真的很大,哈希表可以节省 90% 的合并/连接处理时间.

Obviously if you want to merge/join and re-order then proc sql is the way to go as using a data step to merge requires you to sort first, whereas a proc sql doesn't. And if it really is big, Hash tables can save 90% processing time on merges/joins.

作为小组讨论的一部分的其他成果之一是,当使用大型数据集时,视图在重新排序时的 IO 性能得到改善:

One of the other outcomes as part of the group discussion is when using large datasets the improved IO performance of Views when re-ordering:

proc sql noprint; create view set2 as select title, * from set1; quit; ** OR; data set2 / view=set2; retain title salary name; set set1; run;

(从这里引用:www2.sas/proceedings/sugi27/p019-27.pdf)

更多推荐

在 SAS 中重新排序列的最有效方法

本文发布于:2023-10-24 18:09:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524637.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最有效   序列   方法   SAS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!