BookmarkSubscribeRSS Feed

[RETAIN] 월별 누적 자료 생성

Started ‎06-12-2020 by
Modified ‎06-12-2020 by
Views 74

* 질문 : http://cafe.daum.net/statsas/B3m/14757

 

DATA BACK;

     INPUT Id  month   value;

CARDS;

1 1  5

1 2  7

1 3  6

1 4 11

2 1  4

2 2  2

2 3  3

2 4 11

2 6  1

;

 

DATA BACK_1;

 SET BACK;

     BY ID MONTH;

     ARRAY NEW[*] MON1-MON6;

     * 누젹 변수와 NEW 배열의 원소를 RETAIN;

     RETAIN VAR_SUM NEW;

     * ID값 별로 누적치를 계산;

     IF FIRST.ID THEN VAR_SUM=VALUE;

     ELSE VAR_SUM+VALUE;

 

     * 배열을 사용하여서 해당월의 누적값을 신규 변수로 할당;

     DO I = 1 TO 6;

        IF I=MONTH THEN NEW[I] = VAR_SUM;

     END;

 

     DROP VAR_SUM I MONTH VALUE;

     IF LAST.ID;

RUN;

 
 
***********************************************************
- 통계분석연구회 
- 카페 : http://cafe.daum.net/statsas
- 통계분석연구회 페이지 : https://www.facebook.com/statsas
 

- 통계분석연구회(Statistics Analysis Study) 그룹 :https://www.facebook.com/groups/statsas/ 

Version history
Last update:
‎06-12-2020 04:35 AM
Updated by:
Contributors

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Article Labels
Article Tags