在 SAS 中重新排序列的最有效方法 [英] The most efficient way to reorder columns in SAS

查看:98
本文介绍了在 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),那么完成此操作的最有效方法是什么?带有 retainproc 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;

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

这篇关于在 SAS 中重新排序列的最有效方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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