본문 바로가기

전산Tip/SAS

[SAS] hash를 이용한 row 병합

반응형


data    goals;
        input player $ when & $9.;
datalines;
Hill 1st 01:24
Jones 1st 09:43
Santos 1st 12:45
Santos 2nd 00:42
Santos 2nd 03:46
Jones 2nd 11:15
;

data    _null_;
        length goals_list $ 64;

        if _N_ = 1 then do;
                declare hash h();
                h.defineKey('player');
                h.defineData('player', 'goals_list');
                h.defineDone();
        end;

        set goals end=done;
        if h.find() ^= 0 then do;
                goals_list = when;
                h.add();
        end;
        else do;
                goals_list = trim(goals_list) || ', ' || when;
                h.replace();
        end;

        if done then
                h.output(dataset:'goal_summary');
run;

'전산Tip > SAS' 카테고리의 다른 글

[SAS] proc format  (0) 2011.02.21
[SAS] 오라클vs SAS 테이블 건수 비교  (0) 2011.01.21
[SAS] SAS options mprint  (0) 2011.01.11