SAS proc sql将2列转换为1列

时间:2013-05-22 06:14:03

标签: sas proc-sql

假设我有一张桌子

 A     |  B
===============
Dan    | Jack
April  | Lois
Matt   | Davie
Andrew | Sally

我想制作一张桌子

 C     
======
Dan  
April 
Matt   
Andrew 
Jack
Lois
Davie
Sally

使用SAS proc sql。我怎么能这样做?

3 个答案:

答案 0 :(得分:4)

data have;
input A $ B $;
datalines;
Dan Jack
April Lois
Matt Davie
Andrew Sally
;
run;

proc sql;
create table want as 
select A as name from have
union all
select B as name from have;
quit;

答案 1 :(得分:4)

我知道你要求proc sql,但是这里是你用数据步骤做的。我认为这更容易:

data table2(keep=c);
  set table1;
  c = a;
  output;
  c = b;
  output;
run;

答案 2 :(得分:0)

proc sql;
    create table combine as
    select name
    from one
    union
    select name
    from two;
quit;