• sas宏(3)理解符号表(全局宏与局部宏解析),宏条件运算符,在宏中进行运算


    Understanding the  Global Macro Symbol Table

      Detail

        •The macro processor creates the global macro symbol table at the start of a SAS session.

      Four ways to create add macro to Global Macro Table

        • Create the macro variable in open code.

        • List the macro variable on a %GLOBAL(default value is null) statement in the macro program in which it is defined.

        • Create the macro variable in a DATA step with CALL SYMPUTX when the global symbol table is specified.

        • Define a global macro variable with the INTO clause on the PROC SQL SELECT statement.

      Where and When they can be used?

        You can reference global macro variables throughout the SAS session in which they are created. They can be referenced from open code and from inside macro programs.

      EXAMPLE 

    options symbolgen mprint;
    /*reference in macro program*/
    %let subset=Software;
    %macro makeds;
      data temp;
        set books.ytdsales(where=(section=&subset”));
        attrib qtrsold label='Quarter of Sale';
        qtrsold=qtr(datesold);
      run;
    %mend makeds;
    %makeds
    /*reference in open code*/ 
    proc tabulate data=temp;
      title “Book Sales Report Produced &sysdate9”;
      class qtrsold;
      var saleprice listprice;
      tables qtrsold all,
             (saleprice listprice)*(n*f=6. sum*f=dollar12.2) /
             box=“Section: &subset”;
      keylabel all='** Total **';
    run;

    Understanding the Local Macro Symbol Table

      Detail

        •If your macro program creates macro variables and does not specify them as global macro variables,  the macro processor usually creates a local macro symbol table when that macro program executes,When the macro program finishes, the macro processor deletes the associated local macro symbol table.

      Four ways to create add macro to Global Macro Table

        • Create the macro variable in open code.

        • List the macro variable on a %GLOBAL statement in the macro program in which it is defined.

        • Create the macro variable in a DATA step with CALL SYMPUTX when the global symbol table is specified.

        • Define a global macro variable with the INTO clause on the PROC SQL SELECT statement.

      Where and When they can be used?

        You can reference global macro variables throughout the SAS session in which they are created. They can be referenced from open code and from inside macro programs.

      How to Delete

        A global macro variable can be deleted by macro language statement %SYMDEL

      EXAMPLE 

  • 相关阅读:
    ASP.NET MVC 5 入门(10):添加验证
    ASP.NET MVC 5 入门(09):添加新字段
    MVC5与EF6结合教程(06):创建更复杂的数据模型
    MVC5与EF6结合教程(05):Code First 迁移和部署
    ASP.NET MVC 5 入门(08):添加搜索方法和搜索视图
    ASP.NET MVC 5 入门(07):检查 Edit 方法和编辑视图
    微信小程序入门1:准备
    MVC5与EF6结合教程(04):连接复原和命令截获
    ASP.NET MVC 5 入门(06):控制器访问模型的数据
    ASP.NET MVC 5 入门(05):创建连接字符串并使用 SQL Server LocalDB
  • 原文地址:https://www.cnblogs.com/yican/p/4109376.html
Copyright © 2020-2023  润新知