WHY USE MACROS - WHY USE MACROS MACROS INTRODUCTION The SAS...

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

View Full Document Right Arrow Icon
WHY USE WHY USE MACROS? MACROS?
Image of page 1

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

View Full Document Right Arrow Icon
2 INTRODUCTION The SAS® Macro Language allows you to extend and customize the SAS System to simplify large programs to reduce the amount of text you enter to invoke code several times to minimize the mistakes you might make The macro language is a powerful addition to SAS, allowing increased efficiency and customization of SAS jobs
Image of page 2
3 INTRODUCTION Macro programming is generally considered an advanced topic But, while macros certainly can be challenging, it is also true that the basic concepts are not difficult to learn
Image of page 3

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

View Full Document Right Arrow Icon
4 INTRODUCTION This course is designed for students who know the basics of SAS programming, but know nothing about SAS macro programming As we won’t start from the very beginning, if you are not a SAS user at all, then it is not a course for you
Image of page 4
5 INTRODUCTION We explain how the macro processor works, and how to use macros and macro variables Using these techniques you can create flexible, reusable code that can save you time and effort
Image of page 5

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

View Full Document Right Arrow Icon
6 INTRODUCTION Because macro code takes longer to write and debug than standard SAS code, you generally won’t use macros in programs that will be run only a few times But if you find yourself writing similar code over and over again, then macros may make your job easier
Image of page 6
7 MACROS CAN HELP First, with macros you can make one small change in your program and have SAS echo that change throughout your program Second, macros can allow you to write a piece of code and use it over and over again in the same program or in different programs Third, you can make your programs data driven, letting SAS decide what to do based on actual data values
Image of page 7

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

View Full Document Right Arrow Icon
8 The most important concept to keep in mind whenever you write macro code is that THE MACRO PROCESSOR macro statements standard SAS statements macro processor You are writing a program that writes a program
Image of page 8
9 INTRODUCTION When you submit a standard SAS program, SAS compiles and then immediately executes it But when you write macrocode, there is an extra step
Image of page 9

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

View Full Document Right Arrow Icon
10 INTRODUCTION Before SAS can compile and execute your program, SAS must pass your macro statements to the macro processor which then “resolves” your macros generating standard SAS code Because you are writing a program that writes a program, this is sometimes called meta-programming
Image of page 10
11 Let’s do exercises Scenario 25 data sets with one same variable named TEMP for year 1981 – 2006 YR1981, YR1982, …. , and YR2006 Find mean TEMP for each year PROC MEANS DATA=yr1981; VAR temp; RUN;
Image of page 11

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

View Full Document Right Arrow Icon
12 INTRODUCTION The SAS macro language consists of macro variables, macro programs, macro facility interfaces, and macro storage techniques
Image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

{[ 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