我有数据集,我需要创建一个新列,包含三列。我知道,我应该使用proc报告
I have:
Number Name Food Clothes Weather
01 100 bread socks rain
02 103 apple shirt snow
02 103 milk skirt fog
03 101 meat jacket sun
I need:
Number Name COL
01 100 bread
socks
rain
02 103 apple
shirt
snow
02 103 milk
skirt
fog
03 101 meat
jacket
sun
答案 0 :(得分:0)
不确定为什么要为此使用proc报告。可以用几张表来做到:
data have;
input Number Name Food $ Clothes $ Weather $;
datalines;
01 100 bread socks rain
02 103 apple shirt snow
02 103 milk skirt fog
03 101 meat jacket sun
;
run;
data have2;
set have;
id = _n_;
run;
proc sql;
create table want1 as select
number, name, food as third_var, id
from have2;
create table want2 as select
number, name, clothes as third_var, id
from have2;
create table want3 as select
number, name, weather as third_var, id
from have2;
quit;
data want_stack;
set want1 want2 want3;
proc sort; by number id;
run;