BookmarkSubscribeRSS Feed

[SAS 프로그래밍 고수 백승민] [SQL] 관측치 숫자 제어하기 (INOBS, OUTOBS, MONOTONIC, FIRSTOBS, OBS)

Started ‎06-11-2020 by
Modified ‎06-12-2020 by
Views 96

* 10개의 관측치를 읽어서 5개 관측치 출력출력;
proc sql inobs=10 OUTOBS=5;
  create table back as
    select A.*
    from   sashelp.class A;
quit;

 

 * 관측치 번호를 카운트 하는 MONOTONIC() 함수 사용;

proc sql;
  create table back1 as
    select *
    from   sashelp.class
 where  monotonic()BETWEEN 1 AND 5;
quit;

 

 * 관측치 번호 출력;
proc sql;
  create table back2 as
    select a.*,
        monotonic() as num
    from   sashelp.class a;
quit;

 

 * 3번째 관측치에서 7번째 관측치까지 출력;
DATA BACK3;
 SET SASHELP.CLASS(FIRSTOBS=3 OBS=7);

         NUM = _N_;
RUN;

 

 

 [참고] MONOTONIC() 활용

 [MAX] 변수중에 2번째 큰값 찾기 http://cafe.daum.net/statsas/3F8j/163

데이터 중복제거(first. / last대안) - MAX , MIN : http://cafe.daum.net/statsas/3F8j/162

[SQL] PROC SQL에서 nodupkye 사용(monotonic) : http://cafe.daum.net/statsas/3F8j/70

Version history
Last update:
‎06-12-2020 03:58 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