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

查看:753
本文介绍了在SAS中对列进行重新排序的最有效方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据temp,其中包含变量A1,A2,... Amax.我想重新排列其内部顺序,以便一旦打开它,它将显示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.

作为小组讨论的一部分,其他成果之一是当使用大型数据集时,重新排序后View的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天全站免登陆