From the course: SAS Programming for R Users, Part 2
Unlock this course with a free trial
Join today to access over 22,600 courses taught by industry experts.
Macro programming - SAS Tutorial
From the course: SAS Programming for R Users, Part 2
Macro programming
- [Instructor] In this section, I'll show you how to create a macro program. We'll use macro programs to run SAS code repetitively and we can also run SAS data and PROC steps conditionally or iteratively. You can think of a macro program simply as an R function to provide what ever customization you want. For example, I want to create a macro program called randnorm, where I pass at a single parameter, simply the number of observations I'm going to simulate from a normal distribution. Then, I'll use that data set to generate some reports. For example, I want a table and graphic. We'll do all of this inside of a single program. So an R randnorm would look something like this, I have the function, my single argument, n, I would generate data with the rnorm function, call it vec. I could print some summary statistics and then I can go ahead and create plots based on that data. But, of course, once you type this up once, you can use the function and pass at whatever parameter you want…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
The CORR and FREQ procedures4m 47s
-
(Locked)
The MEANS and UNIVARIATE procedures3m 22s
-
(Locked)
Demo: Ames home sales data exploration4m 15s
-
(Locked)
Selecting output to print and suppress2m 45s
-
(Locked)
Demo: Selecting output with ODS TRACE or the online documentation3m 45s
-
(Locked)
Saving results to new SAS data sets2m 22s
-
(Locked)
Demo: Creating data tables with ODS6m 9s
-
(Locked)
Creating global macro variables: Manually6m 35s
-
(Locked)
Creating global macro variables: Automating the process3m 26s
-
(Locked)
Demo: Creating and using macro variables6m 42s
-
(Locked)
Macro programming3m 56s
-
(Locked)
Creating macro programs with parameters5m 9s
-
(Locked)
Creating macro programs with macro statements: A business example4m 28s
-
(Locked)
Demo: A macro program to generate data, summary statistics, and plots6m 46s
-
(Locked)
Demo: A macro program for iterative processing8m 37s
-