How to make a column of three. SAS

2019-09-09 19:24发布

I have dataset and I need to make a new one column, that consist of three column. I know, that I should use proc report

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

标签: sas
1条回答
倾城 Initia
2楼-- · 2019-09-09 19:42

Not sure why you want to use proc report for this. Can do it with a few tables:

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;
查看更多
登录 后发表回答