본문 바로가기
SAS

[MACRO] 매크로 변수 삭제하기.

by 기서무나구물 2018. 11. 19.

포스팅 목차

    [MACRO] 매크로 변수 삭제하기.

     

    macro view테이블을 사용하여서 symdel함수로 삭제하는 방법이 있어서 올립니다.

     

    [참고]

    %put 으로 매크로 변수 확인;

    _ALL_, _AUTOMATIC_, _GLOBAL_, _LOCAL_, _USER_

    예] %put _user_; * 사용자 정의 매크로 변수 확인;


    http://support.sas.com/kb/26/154.html

     

     

    Sample 26154: Delete all user-defined macro variables from the global symbol table

    /* Please refer to the DETAILS tab for syntax information regarding %SYMDEL. */
    
    %let x=1;
    %let y=2;
    %let z=3;
    
    /* Write macro variable values to the log to show they do have values. */
    %put &x &y &z;
    
    /* VMACRO is a SASHELP view that contains information about currently */
    /* defined macros.  Create a data set from SASHELP.VMACRO to avoid a  */
    /* macro symbol table lock.                                           */
    
    %macro delvars;
      data vars;
        set sashelp.vmacro;
      run;
    
      data _null_;
        set vars;
        temp=lag(name);
        if scope='GLOBAL' and substr(name,1,3) ne 'SYS' and temp ne name then
          call execute('%symdel '||trim(left(name))||';');
      run;
    
    %mend;
    
    %delvars
    
    /* Write macro variable values to the log to show they no longer have values. */
    %put &x &y &z;
    
     
    
     
    
    * PROC SQL처리;
    
     
    
    proc sql noprint;
    select distinct NAME
    into :gmacs
    separated by ' '
    from dictionary.macros
    where upcase(SCOPE) eq 'GLOBAL' and NAME NE 'GMACS';
    quit;
    %symdel &gmacs gmacs;

     

     

    백승민

    님의

    파란블로그

    에서 발행된 글입니다.

     

    반응형

    댓글