90 Pages

mac1c03

Course: STAT 506, Fall 2010
School: Purdue University -...
Rating:
 
 
 
 
 

Word Count: 3721

Document Preview

3: Chapter Macro Definitions 3.1 Defining and Calling a Macro 3.2 Macro Parameters 3.3 Macro Storage (Self-Study) 1 Chapter 3: Macro Definitions 3.1 Defining and Calling a Macro 3.2 Macro Parameters 3.3 Macro Storage (Self-Study) 2 Objectives 3 Define and call a simple macro. Defining a Macro A macro or macro definition enables you to write macro programs. General form of a macro definition: %MACRO...

Register Now

Unformatted Document Excerpt

Coursehero

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
3: Chapter Macro Definitions 3.1 Defining and Calling a Macro 3.2 Macro Parameters 3.3 Macro Storage (Self-Study) 1 Chapter 3: Macro Definitions 3.1 Defining and Calling a Macro 3.2 Macro Parameters 3.3 Macro Storage (Self-Study) 2 Objectives 3 Define and call a simple macro. Defining a Macro A macro or macro definition enables you to write macro programs. General form of a macro definition: %MACRO macro-name;; %MACRO macro-name macro-text macro-text %MEND <macro-name>;; %MEND <macro-name> macro-name macro-text 4 follows SAS naming conventions. can include the following: any text SAS statements or steps macro variable references macro statements, expressions, or calls any combination of the above Macro Compilation When a macro definition is submitted, the following occur: Macro language statements, if any, are checked for syntax errors compiled. SAS statements and other text are not checked for syntax errors not compiled. The macro is stored as a SAS catalog entry in the temporary catalog work.sasmacr by default. 5 Macro Compilation The MCOMPILENOTE=ALL option issues a note to the SAS log after a macro definition has compiled. General form of the MCOMPILENOTE= option: OPTIONS MCOMPILENOTE=ALL|NONE;; OPTIONS MCOMPILENOTE=ALL|NONE The default setting is MCOMPILENOTE=NONE. 6 Macro Compilation Example: Submit a macro definition. options mcompilenote=all; %macro time; %put The current time is %sysfunc (time(),timeampm.).; %mend time; SAS Log 1 options mcompilenote=all; 2 %macro time; 3 %put The current time is %sysfunc 4 (time(),timeampm.).; 5 %mend time; NOTE: The macro TIME completed compilation without errors. 3 instructions 76 bytes. 7 m103d01 Macro Storage Example: Produce a list of compiled macros stored in the default temporary catalog work.sasmacr. proc catalog cat=work.sasmacr; contents; title "My Temporary Macros"; quit; PROC CATALOG Output My Temporary Macros Contents of Catalog WORK.SASMACR # Name Type Create Date Modified Date Description ---------------------------------------------------------------1 TIME MACRO 11JUN2004:15:55:59 11JUN2004:15:55:59 8 m103d02 Calling a Macro A macro call causes the macro to execute is specified by placing a percent sign before the name of the macro can be made anywhere in a program (similar to a macro variable reference) represents a macro trigger is not a statement (no semicolon required). General form of a macro call: %macro-name %macro-name 9 Calling a Macro Example: Call the TIME macro. %time SAS Log 178 %time The current time is 10 10 2:49:39 PM. m103d01 11 11 3.01 Poll Does the macro call below require a semicolon? %time Yes No 12 12 3.01 Poll Correct Answer Does the macro call below require a semicolon? %time Yes No A macro call is not a statement. A semicolon is not required and can cause problems. 13 13 Simple Macro A macro can generate SAS code. Example: Write a macro that generates a PROC MEANS step. Reference macro variables within the macro. %macro calc; proc means data=orion.order_item &stats; var &vars; run; %mend calc; This macro contains no macro language statements. 14 m103d03 Simple Macro Example: Call the CALC macro. Precede the call with %LET statements that populate macro variables referenced within the macro. %let stats=min max; %let vars=quantity; %calc 15 15 m103d03 Program Flow When the macro processor receives %macro-name, it does the following: 1. searches the designated SAS catalog (work.sasmacr by default) for an entry named macro-name.MACRO 2. executes compiled macro language statements, if any 3. sends other text to the input stack for word scanning 4. pauses while the word scanner tokenizes inserted text, and SAS code, if any, compiles and executes 5. resumes execution of macro language statements after SAS code executes 16 16 Program Flow Example: Submit the %LET statements and call the CALC macro. Compiler Symbol Table Word Scanner Macro Processor Input Stack work.sasmacr %let stats=min max; %let stats=min max; %let vars=quantity; %let vars=quantity; %calc %calc # # 1 1 2 2 17 17 Name Name CALC CALC TIME TIME Type Type MACRO MACRO MACRO MACRO ... Program Flow The macro processor executes the %LET statements and populates the symbol table. Compiler Symbol Table STATS min max STATS min max VARS quantity VARS quantity Word Scanner Macro Processor Input Stack work.sasmacr %calc %calc 18 18 # # 1 1 2 2 Name Name CALC CALC TIME TIME Type Type MACRO MACRO MACRO MACRO ... Program Flow When the macro processor receives %CALC, it locates CALC.MACRO within the work.sasmacr catalog. Compiler Symbol Table STATS min max STATS min max VARS quantity VARS quantity Word Scanner Macro Processor %calc %calc Input Stack work.sasmacr # # 1 1 2 2 19 19 Name Name CALC CALC TIME TIME Type Type MACRO MACRO MACRO MACRO ... Program Flow The macro processor opens CALC.MACRO. There are no macro language statements to execute. Compiler Symbol Table STATS min max STATS min max VARS quantity VARS quantity Word Scanner Macro Processor Input Stack CALC.MACRO %macro calc; %macro calc; pproc means data=orion.order_item &stats; roc means data=orion.order_item &stats; var &vars; var &vars; run; run; %mend calc; %mend calc; 20 20 ... Program Flow The macro processor places the macro text on the input stack. Compiler Symbol Table STATS min max STATS min max VARS quantity VARS quantity Word Scanner Macro Processor Input Stack CALC.MACRO proc means data=orion.order_item proc means data=orion.order_item &&stats; stats; vvar &vars; ar &vars; run; run; %macro calc; %macro calc; pproc means data=orion.order_item &stats; roc means data=orion.order_item &stats; var &vars; var &vars; run; run; %mend calc; %mend calc; 21 21 ... Program Flow Macro activity pauses while the word scanner tokenizes text and passes it to the compiler. Compiler proc means data=orion.order_item proc means data=orion.order_item Symbol Table STATS min max STATS min max VARS quantity VARS quantity Word Scanner Macro Processor Input Stack CALC.MACRO &stats; &stats; var &vars; var &vars; run; run; %macro calc; %macro calc; pproc means data=orion.order_item &stats; roc means data=orion.order_item &stats; var &vars; var &vars; run; run; %mend calc; %mend calc; 22 22 ... Program Flow Macro variable references are passed to the macro processor. Compiler proc means data=orion.order_item proc means data=orion.order_item Symbol Table STATS min max STATS min max VARS quantity VARS quantity Word Scanner Macro Processor &stats &stats Input Stack ; ; var &vars; var &vars; run; run; CALC.MACRO 23 23 %macro calc; %macro calc; pproc means data=orion.order_item &stats; roc means data=orion.order_item &stats; var &vars; var &vars; run; run; %mend calc; %mend calc; ... Program Flow Symbolic substitution is performed. Compiler proc means data=orion.order_item proc means data=orion.order_item Symbol Table STATS min max STATS min max VARS quantity VARS quantity Word Scanner Macro Processor &stats &stats Input Stack CALC.MACRO min max; min max; var &vars; var &vars; 24 24 %macro calc; %macro calc; pproc means data=orion.order_item &stats; roc means data=orion.order_item &stats; var &vars; var &vars; run; run; %mend calc; %mend calc; ... Program Flow The word scanner tokenizes the resolved value and passes it to the compiler. Compiler proc means data=orion.order_item proc means data=orion.order_item mmin max; in max; Symbol Table STATS min max STATS min max VARS quantity VARS quantity Word Scanner Macro Processor Input Stack CALC.MACRO var &vars; var &vars; 25 25 %macro calc; %macro calc; pproc means data=orion.order_item &stats; roc means data=orion.order_item &stats; var &vars; var &vars; run; run; %mend calc; %mend calc; ... Program Flow Word scanning continues. Compiler proc means data=orion.order_item proc means data=orion.order_item mmin max; in max; var var Symbol Table STATS min max STATS min max VARS quantity VARS quantity Word Scanner Macro Processor Input Stack CALC.MACRO run; run; 26 26 &vars; &vars; %macro calc; %macro calc; pproc means data=orion.order_item &stats; roc means data=orion.order_item &stats; var &vars; var &vars; run; run; %mend calc; %mend calc; ... Program Flow Macro variable references are passed to the macro processor. Compiler proc means data=orion.order_item proc means data=orion.order_item mmin max; in max; var var Symbol Table STATS min max STATS min max VARS quantity VARS quantity Word Scanner Macro Processor &vars &vars Input Stack CALC.MACRO run; run; %macro calc; %macro calc; pproc means data=orion.order_item &stats; roc means data=orion.order_item &stats; var &vars; var &vars; run; run; %mend calc; %mend calc; 27 27 ; ; ... Program Flow Symbolic substitution is performed. Compiler proc means data=orion.order_item proc means data=orion.order_item mmin max; in max; var var Symbol Table STATS min max STATS min max VARS quantity VARS quantity Word Scanner Macro Processor &vars &vars Input Stack CALC.MACRO run; run; 28 28 quantity; quantity; %macro calc; %macro calc; pproc means data=orion.order_item &stats; roc means data=orion.order_item &stats; var &vars; var &vars; run; run; %mend calc; %mend calc; ... Program Flow The word scanner tokenizes the resolved value and passes it to the compiler. Compiler proc means data=orion.order_item proc means data=orion.order_item mmin max; in max; var qquantity; var uantity; Symbol Table STATS min max STATS min max VARS quantity VARS quantity Word Scanner Macro Processor Input Stack CALC.MACRO run; run; %macro calc; %macro calc; pproc means data=orion.order_item &stats; roc means data=orion.order_item &stats; var &vars; var &vars; run; run; %mend calc; %mend calc; 29 29 ... Program Flow When a step boundary is encountered, SAS executes the compiled step as macro activity remains paused. Macro activity stops when the %MEND statement is encountered. Compiler proc means data=orion.order_item proc means data=orion.order_item mmin max; in max; var quantity; var quantity; Word Scanner Symbol Table STATS min max STATS min max VARS quantity VARS quantity Macro Processor run; run; Input Stack CALC.MACRO %macro calc; %macro calc; pproc means data=orion.order_item &stats; roc means data=orion.order_item &stats; var &vars; var &vars; run; run; %mend calc; %mend calc; 30 30 Macro Execution The SAS log reflects execution of the PROC MEANS step. SAS Log 52 53 54 %let stats=min max; %let vars=quantity; %calc NOTE: There were 732 observations read from the data set ORION.ORDER_ITEM. NOTE: PROCEDURE MEANS used (Total process time): real time 0.03 seconds cpu time 0.03 seconds PROC MEANS source code does not appear in the SAS log. 31 31 m103d03 Macro Execution The MPRINT option writes to the SAS log the text sent to the SAS compiler as a result of macro execution. General form of the MPRINT|NOMPRINT option: OPTIONS MPRINT; OPTIONS MPRINT; OPTIONS NOMPRINT; OPTIONS NOMPRINT; The default setting is NOMPRINT. 32 32 Macro Execution Example: Set the MPRINT option before calling the macro. Partial SAS Log 55 options mprint; 56 %calc MPRINT(CALC): proc means data=orion.order_item min max; MPRINT(CALC): var quantity; MPRINT(CALC): run; NOTE: There were 732 observations read from the data set ORION.ORDER_ITEM. NOTE: PROCEDURE MEANS used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 33 33 34 34 Exercise This exercise reinforces the concepts discussed previously. 35 35 Chapter 3: Macro Definitions 3.1 Defining and Calling a Macro 3.2 Macro Parameters 3.3 Macro Storage (Self-Study) 36 36 Objectives Define and call macros with parameters. Describe the difference between positional parameters and keyword parameters. 37 37 Review Example: Note macro variable references within the CALC macro. %macro calc; proc means data=orion.order_item &stats; var &vars; run; %mend calc; 38 38 m103d03 Review Example: Call the macro twice, each time with different values of the macro variables STATS and VARS. %let stats=min max; %let vars=quantity; %calc %let stats=n mean; %let vars=discount; %calc The user must submit three lines each time. How can this be simplified? 39 39 m103d03 Macro Parameters Example: Define a macro with a parameter list of macro variables referenced within the macro. %macro calc(stats,vars); proc means data=orion.order_item &stats; var calc; 40 40 m103d05 Positional &vars; run; %mend Parameters Positional parameters use a one-to-one correspondence between the following: parameter names supplied on the macro definition parameter values supplied on the macro call %macro calc(stats,vars); proc means data=orion.order_item &stats; var &vars; run; %mend calc; %calc(min max,quantity) 41 m103d05 Positional Parameters General form of a macro definition with positional parameters: %MACRO macro-name((parameter-1, parameter-n); %MACRO macro-name parameter-1, parameter-n); macro text macro text %MEND <macro-name>;; %MEND <macro-name> Parameter names are parenthesized comma delimited. 42 42 Macro Parameters General form of a macro call with parameters: %macro-name((value-1, value-n)) %macro-name value-1, value-n Parameter values are parenthesized comma delimited. Parameter values can be any text, null values, macro variable references, or macro calls. 43 43 Local Symbol Tables When a macro with a parameter list is called, the parameters are created in a separate local symbol table. The macro call %calc(min max, quantity) initializes a local table: Local Table STATS min max VARS quantity 44 Global Table SYSDAY Tuesday SYSLAST _NULL_ CITY Dallas AMOUNT 975 Local Symbol Tables A local symbol table is created when a macro with a parameter list is called deleted when the macro finishes execution. Macro variables in the local table are available only during macro execution and can be referenced only within the macro. 45 45 46 46 3.02 Multiple Choice Poll A %LET statement outside a macro definition creates a macro variable in the a. b. 47 47 global symbol table local symbol table 3.02 Multiple Choice Poll Correct Answer A %LET statement outside a macro definition creates a macro variable in the a. b. 48 48 global symbol table local symbol table Positional Parameters Example: Define and call a macro with positional parameters. %macro count(opts, start, stop); proc freq data=orion.orders; where order_date between "&start"d and "&stop"d; table order_type / &opts; title1 "Orders from &start to &stop"; run; %mend count; options mprint; %count(nocum,01jan2004,31dec2004) %count(,01jul2004,31dec2004) 49 49 m103d06a Macros with Positional Parameters m103d06a This demonstration illustrates using positional parameters to specify a range of dates and TABLE statement options for the FREQ procedure. 50 50 Keyword Parameters A parameter list can include keyword parameters. General form of a macro definition with keyword parameters: %MACRO macro-name((keyword=value,, keyword=value); %MACRO macro-name keyword=value, , keyword=value); macro text macro text %MEND <macro-name>;; %MEND <macro-name> Keyword parameters are assigned a default value after an equal (=) sign. 51 51 Keyword Parameters General form of a macro call with keyword parameters: %macro-name((keyword=value,, keyword=value)) %macro-name keyword=value, , keyword=value keyword=value combinations can be specified in any order omitted from the call without placeholders. If omitted from the call, a keyword parameter receives its default value. 52 Keyword Parameters Example: Assign default parameter values by defining the macro with keyword parameters. %macro count(opts=,start=01jan04,stop=31dec04); proc freq data=orion.orders; where order_date between "&start"d and "&stop"d; table order_type / &opts; title1 "Orders from &start to &stop"; run; %mend count; options mprint; %count(opts=nocum) %count(stop=01jul04,opts=nocum nopercent) %count() 53 53 m103d06b Macros with Keyword Parameters m103d06b This demonstration illustrates the use of keyword parameters. 54 54 55 55 3.03 Quiz Submit program m103a01. %macro dog(name=spot); %put My dog is &name; %mend dog; %dog() Edit the program to omit the parentheses. Submit the macro call. %dog What do you see in the SAS log? 56 56 3.03 Quiz Correct Answer Edit the program to omit the parentheses. Submit the macro call. %dog What do you see in the SAS log? 67 %dog() My dog is spot 68 %dog The macro call will not execute without parentheses. 57 Mixed Parameter Lists You can use a combination of positional and keyword parameters. In a mixed parameter list, positional parameters must be listed before keyword parameters in both the macro definition and the macro call. 58 58 Mixed Parameter Lists Example: Use a combination of positional and keyword parameters. %macro count(opts,start=01jan04,stop=31dec04); proc freq data=orion.orders; where order_date between "&start"d and "&stop"d; table order_type / &opts; title1 "Orders from &start to &stop"; run; %mend count; options mprint; %count(nocum) %count(stop=30jun04,start=01apr04) %count(nocum nopercent,stop=30jun04) %count() 59 59 m103d06c Macros with Mixed Parameter Lists m103d06c This demonstration illustrates the use of a mixed parameter list. 60 60 61 61 Exercise This exercise reinforces the concepts discussed previously. 62 62 Chapter 3: Macro Definitions 3.1 Defining and Calling a Macro 3.2 Macro Parameters 3.3 Macro Storage (Self-Study) 63 63 Objectives 64 64 Use stored compiled macros to make macros available to a SAS program. Use the autocall facility to make macros available to a SAS program. Review Example: Produce a list of session-compiled macros stored in the default temporary catalog, work.sasmacr. proc catalog cat=work.sasmacr; contents; title "My Temporary Macros"; quit; PROC CATALOG Output My Temporary Macros Contents of Catalog WORK.SASMACR # Name Type Create Date Modified Date Description -------------------------------------------------------------------1 CALC MACRO 15JUN2007:15:58:21 15JUN2007:15:58:21 2 TIME MACRO 15JUN2007:15:55:59 15JUN2007:15:55:59 65 65 m103d02 Stored Compiled Macros The MSTORED system option enables storage of compiled macros in a permanent library. The SASMSTORE= system option designates a permanent library to store compiled macros. OPTIONS MSTORED SASMSTORE=libref ;; OPTIONS MSTORED SASMSTORE=libref libref 66 66 points to an allocated SAS data library. Stored Compiled Macros General form of a macro definition for permanent stored compiled macros: %MACRO macro-name // STORE; %MACRO macro-name STORE; macro-text macro-text %MEND macro-name;; %MEND macro-name The STORE option stores the compiled macro in the library indicated by the SASMSTORE= system option. 67 67 Stored Compiled Macros Example: Store the CALC macro in a permanent library. options mstored sasmstore=orion; %macro calc / store; proc means data=orion.order_item &stats; var &vars; run; %mend calc; Call the CALC macro in a new SAS session. options mstored sasmstore=orion; %let stats=min max; %let vars=quantity; %calc 68 68 m103d04a The Autocall Facility SAS software includes an autocall library of utility macros. 69 69 The Autocall Facility An autocall library is a collection of external files or SAS catalog SOURCE entries that contain macro definition source code. You can make macros accessible to your SAS session or job by concatenating your own autocall library or your organization's autocall library (or both) with the autocall library supplied with SAS software. 70 70 Defining an Autocall Library To define an autocall library: 1. Specify the MAUTOSOURCE SAS system option. 2. Use the SASAUTOS= SAS system option to identify autocall library locations. 71 71 Autocall Facility System Options The MAUTOSOURCE option controls autocall facility availability. General form of the MAUTOSOURCE|NOMAUTOSOURCE option: OPTIONS MAUTOSOURCE; OPTIONS MAUTOSOURCE; OPTIONS NOMAUTOSOURCE; OPTIONS NOMAUTOSOURCE; The default setting is MAUTOSOURCE. 72 72 Autocall Facility System Options The SASAUTOS= system option specifies the location of autocall macros. General form of the SASAUTOS= system option: OPTIONS SASAUTOS=(library-1,...,library-n); OPTIONS SASAUTOS=(library-1,...,library-n); The values of library-1 through library-n are references to source libraries containing macro definitions. You specify a source library by doing one of the following: placing its name in quotation marks pointing to it with a fileref 73 73 Autocall Facility System Options Example: Concatenate the autocall library supplied by SAS with your personal autocall library and/or your organization's autocall library. Windows: options mautosource sasautos=('s:\workshop',sasautos); UNIX: options mautosource sasautos=('/workshop','!SASROOT/sasautos'); z/OS: options mautosource sasautos=('my.macros',sasautos); The reserved fileref SASAUTOS is assigned to the autocall library supplied by SAS. 74 74 The Autocall Facility in Windows or UNIX In a Windows or UNIX environment, save each macro definition as a separate file within the directory specified in the SASAUTOS= option. Ensure that the following are true: Filenames have a .sas extension. The filename and the macro name match. UNIX filenames are lowercase. 75 75 The Autocall Facility in z/OS In a z/OS environment, save each macro definition as a separate member of the partitioned data set specified in the SASAUTOS= option. The member name and the macro name must match. A JCL DD statement with a DDname of SASAUTOS can allocate an autocall library. 76 76 Accessing Autocall Macros With the autocall facility in effect, you can call any macro in the autocall library. If you call a macro that was not previously compiled, the macro facility takes these actions: searches the autocall library for a member with the same name as the called macro issues an error message if the member is not found executes the macro source statements to compile the macro if the member is found calls the macro 77 77 78 78 3.04 Quiz What does the macro processor do when an autocall macro is called for the first time within a session? 79 79 3.04 Quiz Correct Answer What does the macro processor do when an autocall macro is called for the first time within a session? The macro processor compiles an autocall macro the first time the macro is called within the session. 80 80 Accessing Autocall Macros Is a compiled macro available? Ye s Execute the compiled macro No WARNING: Apparent invocation of macro not resolved No Does the macro exist in an autocall library? Ye s Execute the source statements to compile the macro 81 81 Execute the compiled macro The Autocall Facility Example: Save the CALC macro in an autocall library as calc.sas. Step 1: options mautosource sasautos=('s:\workshop',sasautos); Step 2: %macro calc; proc means data=orion.order_item &stats; var &vars; run; %mend calc; Step 3: continued... 82 82 m103d04b The Autocall Facility Step 4: Call the CALC macro in a new SAS session. options mautosource sasautos=('s:\workshop',sasautos); %let stats=min max; %let vars=quantity; %calc 83 83 m103d04b Macro Storage Advice Advantages of stored compiled macros: You avoid re-compiling lengthy macro source code. Macro source code can be protected or hidden. Advantages of autocall macros: They are available cross-platform. Macro source code can be edited in any text editor without invoking SAS. If none of the above considerations apply, use whichever technique is preferred in your organization or whichever technique you prefer. 84 84 85 85 Exercise This exercise reinforces the concepts discussed previously. 86 86 Chapter Review 1. What statement begins a macro definition? 2. What statement ends a macro definition? 3. What statement causes the log to display a note when a macro definition is compiled? 4. How is a macro called? 87 87 Chapter Review Correct Answers 1. What statement begins a macro definition? %MACRO 2. What statement ends a macro definition? %MEND 3. What statement causes the log to display a note when a macro definition is compiled? OPTIONS MCOMPILENOTE=ALL; 4. How is a macro called? %macro-name 88 88 Chapter Review 5. What statement causes the log to display SAS code sent to the compiler as a result of macro execution? 6. What are the two types of macro parameters? 7. Where are macro parameters stored? 8. With a mixed parameter list, which type of parameter must be listed first? 89 89 Chapter Review Correct Answers 5. What statement causes the log to display SAS code sent to the compiler as a result of macro execution? OPTIONS MPRINT; 6. What are the two types of macro parameters? Positional parameters and keyword parameters 7. Where are macro parameters stored? In a local symbol table 90 90 8. With a mixed parameter list, which type of parameter must be listed first? Positional parameters
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Purdue University - Main Campus - STAT - 506
Chapter 4: DATA Step and SQL Interfaces4.1 Creating Macro Variables in the DATA Step4.2 Indirect References to Macro Variables4.3 Retrieving Macro Variables in the DATA Step(Self-Study)4.4 Creating Macro Variables in SQL1Chapter 4: DATA Step and SQ
Purdue University - Main Campus - STAT - 506
Chapter 5: Macro Programs5.1 Conditional Processing5.2 Parameter Validation5.3 Iterative Processing5.4 Global and Local Symbol Tables1Chapter 5: Macro Programs5.1 Conditional Processing5.2 Parameter Validation5.3 Iterative Processing5.4 Global a
Purdue University - Main Campus - STAT - 506
Chapter 6: Learning More6.1: SAS Resources6.2: Beyond This Course1Chapter 6: Learning More6.1: SAS Resources6.2: Beyond This Course2Objectives3Identify areas of support that SAS offers.EducationComprehensive training to deliver greater valuet
Purdue University - Main Campus - STAT - 506
Chapter 1: Introduction1.1 Course Logistics1.2 An Overview of Foundation SAS1Chapter 1: Introduction1.1 Course Logistics1.2 An Overview of Foundation SAS2Objectives3Explain the naming convention that is used for thecourse files.Compare the thr
Purdue University - Main Campus - STAT - 506
Chapter 2: Getting Started with SAS2.1 Introduction to SAS Programs2.2 Submitting a SAS Program1Chapter 2: Getting Started with SAS2.1 Introduction to SAS Programs2.2 Submitting a SAS Program2Objectives3List the components of a SAS program.Stat
Purdue University - Main Campus - STAT - 506
Chapter 3: Working with SAS Syntax3.1 Mastering Fundamental Concepts3.2 Diagnosing and Correcting Syntax Errors1Chapter 3: Working with SAS Syntax3.1 Mastering Fundamental Concepts3.2 Diagnosing and Correcting Syntax Errors2Objectives3Identify t
Purdue University - Main Campus - STAT - 506
Chapter 4: Getting Familiar withSAS Data Sets4.1 Examining Descriptor and Data Portions4.2 Accessing SAS Data Libraries4.3 Accessing Relational Databases (Self-Study)1Chapter 4: Getting Familiar withSAS Data Sets4.1 Examining Descriptor and Data P
Purdue University - Main Campus - STAT - 506
Chapter 5: Reading SAS Data Sets5.1 Introduction to Reading Data5.2 Using SAS Data as Input5.3 Subsetting Observations and Variables5.4 Adding Permanent Attributes1Chapter 5: Reading SAS Data Sets5.1 Introduction to Reading Data5.2 Using SAS Data
Purdue University - Main Campus - STAT - 506
Chapter 6: Reading Excel Worksheets6.1 Using Excel Data as Input6.2 Doing More with Excel Worksheets (Self-Study)1Chapter 6: Reading Excel Worksheets6.1 Using Excel Data as Input6.2 Doing More with Excel Worksheets (Self-Study)2Objectives3Use th
Purdue University - Main Campus - STAT - 506
Chapter 7: Reading Delimited Raw Data Files7.1 Using Standard Delimited Data as Input7.2 Using Nonstandard Delimited Data as Input1Chapter 7: Reading Delimited Raw Data Files7.1 Using Standard Delimited Data as Input7.2 Using Nonstandard Delimited D
Purdue University - Main Campus - STAT - 506
Chapter 8: Validating and Cleaning Data8.1 Introduction to Validating and Cleaning Data8.2 Examining Data Errors When Reading Raw Data Files8.3 Validating Data with the PRINT and FREQ Procedures8.4 Validating Data with the MEANS andUNIVARIATE Procedu
Purdue University - Main Campus - STAT - 506
Chapter 9: Manipulating Data9.1 Creating Variables9.2 Creating Variables Conditionally9.3 Subsetting Observations1Chapter 9: Manipulating Data9.1 Creating Variables9.2 Creating Variables Conditionally9.3 Subsetting Observations2Objectives3Crea
Purdue University - Main Campus - STAT - 511
Statistical Methods (STAT 511)Midterm #1, Spring 20118:00-10:00pm, LWSN B155Thursday, February 24, 2011There are totally 27 points in the exam. The students with score higher than or equal to 25points will receive 25 points. Please write down your na
Purdue University - Main Campus - STAT - 511
Statistical Methods (STAT 511)Midterm #1, Spring 20118:00-10:00pm, LWSN B155Thursday, February 24, 2011There are totally 27 points in the exam. The students with score higher than or equal to 25points will receive 25 points. Please write down your na
Purdue University - Main Campus - STAT - 511
STAT 511Midterm 1Formula SheetnSample mean y yi 1niynnSample variance s 2 yi y 2i 1n 1nyi 12i ny 2n 1nSample standard deviation (SD) s Pk ,n n!,(n k )! yi y 2i 1n 1 n Pk ,nn! k k ! k !(n k )!Binomial distribution, Y ~
Purdue University - Main Campus - STAT - 511
Homework1_Spring2012Page 1Homework1_Spring2012Page 2Homework1_Spring2012Page 3Homework1_Spring2012Page 4
Purdue University - Main Campus - STAT - 511
Homework2Page 1Homework2Page 2Homework2Page 3Homework2Page 4
Purdue University - Main Campus - STAT - 511
Homework3Page 1Homework3Page 2Homework3Page 3Homework3Page 4Homework3Page 5
Purdue University - Main Campus - STAT - 511
STAT 511-2 Homework 1Page 1STAT 511-2 Homework 1Page 2STAT 511-2 Homework 1Page 3STAT 511-2 Homework 1Page 4STAT 511-2 Homework 1Page 5STAT 511-2 Homework 1Page 6STAT 511-2 Homework 1Page 7
Purdue University - Main Campus - STAT - 511
STAT 511-2 Homework 2Page 1STAT 511-2 Homework 2Page 2STAT 511-2 Homework 2Page 3STAT 511-2 Homework 2Page 4
Purdue University - Main Campus - STAT - 511
STAT 511 Homework 3Page 1STAT 511 Homework 3Page 2STAT 511 Homework 3Page 3STAT 511 Homework 3Page 4
Purdue University - Main Campus - STAT - 511
STAT 511-2 Homework 4 SolutionsPage 1STAT 511-2 Homework 4 SolutionsPage 2STAT 511-2 Homework 4 SolutionsPage 3
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversityFall 2011Lecture 6: Populations, Samples and ProcessesDevore: Section 1.1-1.2Oct, 2011Page 1Statistics 511: Statistical MethodsDr. LevinePurdue UniversityFall 2011Populations and Sa
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversityFall 2011Lecture 2: Measures of Location and VariabilityDevore: Section 1.3-1.4Oct, 2011Page 1Statistics 511: Statistical MethodsDr. LevinePurdue UniversityFall 2011Sample mean The
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversityFall 2011Lecture 1: Introduction to Probability. Sample spaces, events, probabilityaxiomsDevore: Section 2.1-2.2Aug, 2011Page 1Statistics 511: Statistical MethodsDr. LevinePurdue Uni
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySpring 2012Lecture 4: Counting Techniques, Conditional Probability and IndependenceDevore: Section 2.3-2.5Jan 2012Page 1Statistics 511: Statistical MethodsDr. LevinePurdue University
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySpring 2011Lecture 5: Discrete Random Variables, Distributions and MomentsDevore: Section 3.1-3.3Feb, 2011Page 1Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySpring 2
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversityFall 2011Lecture 6: The Binomial, Hypergeometric, Negative Binomialand Poisson DistributionsDevore: Section 3.4-3.6Sept, 2011Page 1Statistics 511: Statistical MethodsDr. LevinePurdue
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySpring 2011Lecture 8: Continuous Random Variables: an IntroductionDevore: Section 4.1-4.3Feb, 2011Page 1Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySpring 2011Cont
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversityFall 2011Lecture 10: Other Continuous Distributions and ProbabilityPlotsDevore: Section 4.4-4.6October, 2011Page 1Statistics 511: Statistical MethodsDr. LevinePurdue UniversityFall
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversityFall 2011Lecture 12: Some general concepts of point estimationDevore: Section 6.1October, 2011Page 1Statistics 511: Statistical MethodsDr. LevinePurdue UniversityFall 2011Point esti
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversityFall 2011Lecture 11: Random Samples, Weak Law of Large Numbersand Central Limit TheoremDevore: Section 5.3-5.5October, 2011Page 1Statistics 511: Statistical MethodsDr. LevinePurdue U
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySpring 2011Lecture 12: Condence IntervalsDevore: Section 7.1-7.2March, 2011Page 1Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySpring 2011Motivation Why do we need
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySpring 2011Lecture 13: Additional Condence Intervals Related TopicsDevore: Section 7.3-7.4March, 2011Page 1Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySpring 2011t
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySpring 2011Lecture 14: Introduction to Hypothesis TestingDevore: Section 8.1March, 2011Page 1Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySpring 2011What is statist
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySpring 2011Lecture 15: Tests about Population Means and PopulationProportionsDevore: Section 8.2-8.3April, 2011Page 1Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySp
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySpring 2011Lecture 17: P-values and some Additional Issues concerningTestingDevore: Section 8.4-8.5April, 2011Page 1Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySpr
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySpring 2011Lecture 18: Inferences Based on Two SamplesDevore: Section 9.1-9.3Apr, 2011Page 1Statistics 511: Statistical MethodsDr. LevinePurdue UniversitySpring 2011z Tests and Cond
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversityFall 2010Lecture 19: One-way Analysis of Variance (ANOVADevore: Section 10.1-10.3Aug, 2010Page 1Statistics 511: Statistical MethodsDr. LevinePurdue UniversityFall 2010Introduction
Purdue University - Main Campus - STAT - 511
Statistics 511: Statistical MethodsDr. LevinePurdue UniversityFall 2011Lecture : Simple linear regression: Model and its estimationDevore: Section 12.1-12.2Dec, 2011Page 1Statistics 511: Statistical MethodsDr. LevinePurdue UniversityFall 2011
Purdue University - Main Campus - STAT - 511
STAT 511-2Spring 2012J a n 9, 2012Jun Xie1. Go over the course syllabus and confirm the midterm schedules and office hours.Ch 1 Introduction and Descriptive StatisticsStatistics is the science of understanding data and of making decisions in the fac
Purdue University - Main Campus - STAT - 511
STAT 511-2Spring 2012Jan 11, 2012Jun Xie1. Finish the remaining contents from last lecture on graphical representations of data.1.2 Pictorial methods in descriptive statistics Making histogramExample stem length for peppers (n=15)12.412.213.410
Purdue University - Main Campus - STAT - 511
STAT 511-2Spring 2012Jan 13, 2012Jun Xie1. Summary of graphical tools.1.3 Measures of locationSample MeanExample 14 crack length of iron and steel (m)x1 = 16.1 x2 = 9.6 x3 = 24.9 x4 = 20.4 x5 = 12.7x6 = 21.2 x7 = 30.2 x8 = 25.8 x9 = 18.5 x10 = 10
Purdue University - Main Campus - STAT - 511
STAT 511-2Spring 2012Lecture 5Jan 20, 2012Jun Xie2 Introduction of ProbabilityProbability is a chance measurement defined on sample space and for events of a random experiment.An experiment is any activity or process whose outcome is subject to unc
Purdue University - Main Campus - STAT - 511
STAT 511-2Spring 2012Lecture 6Jan 23, 2012Jun XieFinish Example 13 and 16, more probability propositions, and equally likely outcomes from last post.2.3 Counting TechniquesProduct rule for ordered pairsOrdered pair: if O1 and O2 are objects, then
Purdue University - Main Campus - STAT - 511
STAT 511-2Spring 2012Lecture 7Jan 25, 2012Jun XieFinish the formulas of permutation and combination, and the examples in the last post.2.3 Counting TechniquesA little more complicated counting problemExample 22 A particular iPod playlist contains
Purdue University - Main Campus - STAT - 511
STAT 511-2Spring 2012Lecture 8Jan 27, 2012Jun XieExtra example on counting from the homework problem; Finish the definition of conditional probabilityand examples in the last post.2.4 Conditional probabilityThe multiplication ruleSimilarly, consi
Purdue University - Main Campus - STAT - 511
STAT 511-2Spring 2012Lecture 9Jan 30, 2012Jun XieReview the Bayes theorem and go over examples.2.5 IndependenceDefinitionTwo events A and B are independent if P(A | B) = P(A) and are dependent otherwise.PropositionA and B are independent if and
Purdue University - Main Campus - STAT - 511
STAT 511-2Spring 2012Lecture 10Feb 1, 2012Jun Xie3. Discrete random variables and probability distributionsRandom variables are numerical representations of outcomes of a random experiment.DefinitionFor a given sample space S of some experiment, a
Purdue University - Main Campus - STAT - 511
STAT 511-2Spring 2012Lecture 11Feb 3, 2012Jun Xie3.4 The binomial probability distributionAn experiment that satisfies the following conditions is called a binomial experiment.1. The experiment consists of a sequence of n smaller experiments called
Purdue University - Main Campus - STAT - 511
Purdue University - Main Campus - STAT - 511
STAT 511-2Spring 2012Lecture 13Feb 8, 2012Jun XieFinish contents from the last post, Poisson distribution and pdf of continuous rv.4.1 Probability density function (continued)DefinitionA continuous rv X is said to have a uniform distribution on th
Purdue University - Main Campus - STAT - 511
STAT 511-2Spring 2012Lecture 14Feb 10, 2012Jun XieFinish the content of cumulative distribution function in the last post.4.2Expected valuesDefinitionThe expected or mean value of a continuous rvX with pdf f (x) is x = E(X) =PropositionIf X is
Purdue University - Main Campus - STAT - 511
STAT 511-2Spring 2012Lecture 15Feb 13, 2012Jun Xie4.3 The normal distributionThe standard normalDefinitionThe normal distribution with parameter values = 0 and = 1 is called the standard normaldistribution.A random variable having a standard nor
Purdue University - Main Campus - STAT - 511
STAT 511-2Spring 2012Lecture 16Feb 17, 2012Jun Xie4.3 The normal distributionExample 16 Reaction time for an in-traffic response to a brake signal from standard brake lights can bemodeled with a normal distribution having mean value 1.25 sec and st
Purdue University - Main Campus - STAT - 511
STAT 511-2Spring 2012Lecture 17Feb 20, 2012Jun Xie4.4 The exponential distributionThe exponential distribution is frequently used as a model for the distribution of times between theoccurrence of successive events, such as customers arriving at a s
Purdue University - Main Campus - STAT - 511
Purdue University - Main Campus - STAT - 511
Purdue University - Main Campus - STAT - 511
Solution for Quiz 01=.3751
Purdue University - Main Campus - STAT - 511
Name:ANSWER.Statistics 511-2, Quiz 2An electronics store has received a shipment of 20 table radios with connections for externaldevices. Twelve of them have two connection slots, and the other eight have a single slot.Suppose that six of the 20 rad
Purdue University - Main Campus - STAT - 511
STAT511Exam 1Summer 2008(50 pts) I. Multiple choice1. Which of the following is not correct?A Mutually exclusive events must be independent eventsB P (A B ) P (A)C Axioms of probability say that for two events A1 and A2 are mutually exclusive,we h