WHY USE MACROS - WHY USE MACROS? MACROS? INTRODUCTION The...

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

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

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

View Full DocumentRight 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
Background 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
Background image of page 3

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

View Full DocumentRight 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
Background 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
Background image of page 5

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

View Full DocumentRight 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
Background 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
Background image of page 7

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

View Full DocumentRight 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
Background 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
Background image of page 9

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

View Full DocumentRight 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
Background 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;
Background image of page 11

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

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

This note was uploaded on 12/08/2010 for the course USE 3425 taught by Professor Raman during the Spring '10 term at Punjab Engineering College.

Page1 / 38

WHY USE MACROS - WHY USE MACROS? MACROS? INTRODUCTION The...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online