y****1 发帖数: 400 | 1 头昏了,觉得应该很容易就搞定的。
我现在有2个SAS数据集想要垂直合并,就是第一个数据集的第一列跟第二个数据集的第
一列垂直合并
(append),以此类推。变量的个数是一样的,但是变量名不一样。要用什么命令啊?
多谢多谢! |
C******t 发帖数: 72 | 2 proc sql;
create table combined
as
select *
from table1
UNION all
select *
from table2; |
y****1 发帖数: 400 | 3 先多谢哈!
我不用sql的原因就是sql对observation的顺序没有保证,但是我数据集里每个
observation的位
置非常重要,就担心这样合并的时候顺序会有变。
还是all跟union一起用的话就一定是simply append呢?
多谢啦:)
【在 C******t 的大作中提到】![](/moin_static193/solenoid/img/up.png) : proc sql; : create table combined : as : select * : from table1 : UNION all : select * : from table2;
|
s*r 发帖数: 2757 | 4 这样能让第一表的第一列在第二个表的第一列上面吗
【在 C******t 的大作中提到】![](/moin_static193/solenoid/img/up.png) : proc sql; : create table combined : as : select * : from table1 : UNION all : select * : from table2;
|
C******t 发帖数: 72 | 5 I am not sure about that. If that does't work as you want, you can rename
the variable first and use append to combine data. |
y****1 发帖数: 400 | 6 Yeah the problems are:
1. There is no way to check whether the SQL procedure changed my
observation sequence
2. I have close to 7,000 variables so it is impossible to rename them
all...
rename
【在 C******t 的大作中提到】![](/moin_static193/solenoid/img/up.png) : I am not sure about that. If that does't work as you want, you can rename : the variable first and use append to combine data.
|
s*r 发帖数: 2757 | 7 我给你出个搜主义吧
先把两个表transpose,然后直接横向merge,再transpose回来
【在 y****1 的大作中提到】![](/moin_static193/solenoid/img/up.png) : Yeah the problems are: : 1. There is no way to check whether the SQL procedure changed my : observation sequence : 2. I have close to 7,000 variables so it is impossible to rename them : all... : : rename
|
N**D 发帖数: 10322 | 8 perl
【在 y****1 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 头昏了,觉得应该很容易就搞定的。 : 我现在有2个SAS数据集想要垂直合并,就是第一个数据集的第一列跟第二个数据集的第 : 一列垂直合并 : (append),以此类推。变量的个数是一样的,但是变量名不一样。要用什么命令啊? : 多谢多谢!
|
y****1 发帖数: 400 | 9 This is a GREAT idea.
Also I have fewer observations than variables, so it actually will work
faster.
Thank you sooooooo much.
【在 s*r 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 我给你出个搜主义吧 : 先把两个表transpose,然后直接横向merge,再transpose回来
|
C******t 发帖数: 72 | 10 很简单,用table number, rownumber来排序.
data set1;
input x y;
datalines;
1 2
3 4
5 6
;
data set2;
input w z;
datalines;
3 4
;
run;
data set1;
set set1;
setn=1;
rown=_n_;
run;
data set2;
set set2;
setn=2;
rown=_n_;
run;
proc sql;
create table combined (drop=setn rown)
as
select *
from set1
UNION all
select *
from set2
order by setn, rown; |