SAS_Macro[1] - MACROLANGUAGE 1 MacroFacility ustousemacros...

Info icon This preview shows pages 1–9. Sign up to view the full content.

  1 MACRO LANGUAGE MACRO LANGUAGE
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

  2 Macro Facility - Macro Facility -     The SAS macro facility is a tool within Base SAS  software that contains the essential elements that enable  us to use macros.    The macro facility contains a macro processor that  translates macro code into statements that is used by the  SAS system, and the macro language.       INTRODUCTION TO MACROS INTRODUCTION TO MACROS
Image of page 2
  3 Macro Facility - Macro Facility -    Macro language provides the means to communicate  with the macro processor.    Macro language consists of its own set of commands,  options, syntax and compiler.       INTRODUCTION TO MACROS INTRODUCTION TO MACROS
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

  4 Macro Language Tools - Macro Language Tools -    Macro language provides tools that     Pass information between SAS steps.    Dynamically create code at execution time.    Conditionally execute DATA or PROC steps.    Create generalized and flexible code.       INTRODUCTION TO MACROS INTRODUCTION TO MACROS
Image of page 4
  5       INTRODUCTION TO MACROS` INTRODUCTION TO MACROS` Defining A Macro - Defining A Macro - Any macro code should be with in the two macro  language statements  %Macro  and  %Mend . Syntax  : -    %Macro  macro-name; - - - - Macro - - text;          %Mend  <macro-name>; Note :-  No macro name can begin with ‘ sys ’ or the name of a SAS         supplied macro statement  or a macro function.
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

  6 SAS Code       INTRODUCTION TO MACROS INTRODUCTION TO MACROS Example Example %Macro  Print; Proc Print Data=& dname ; Title "The Data Set Name & dname "; Run;  %Mend  Print; Note: To resolve macro variable in a macro, use double quote Proc Print Data=Sample; Title ‘The Data Set Name Sample’; Run; Macro Code ->
Image of page 6
  7       INTRODUCTION TO MACROS INTRODUCTION TO MACROS Macros are called by placing a (%) before the macro  name.  Example:-          %Macro  Sort;                 Proc Sort Data=&dname;                 By &var1;        Run;        %Mend  Sort;          %Let dname=First;           %Let var1=duns;               %Sort ;              Calling A Macro - Calling A Macro -
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

  8 Defining Macro Variables Defining Macro Variables    Macro variables are also known as symbolic  variables.   Macro variables are  not dataset variables but they  belong to SAS macro language.   Once a macro variable is defined it can take any  value during the execution of a SAS program.
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.
  • Spring '10
  • Raman

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern