Retrieving Macro Variables in the DATA Step

Slides:



Advertisements
Similar presentations
©2011, Veridical Solutions. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc.
Advertisements

Examples from SAS Functions by Example Ron Cody
Chapter 9: Introducing Macro Variables 1 © Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Outline Proc Report Tricks Kelley Weston. Outline Examples 1.Text that spans columnsText that spans columns 2.Patient-level detail in the titlesPatient-level.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
SAS Programming: Working With Variables. Data Step Manipulations New variables should be created during a Data step Existing variables should be manipulated.
VBA Modules, Functions, Variables, and Constants
Chapter 8 Overview – Learn to use try catch blocks – Learn to use streams – Learn to use text files.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
By Mary Anne Poatsy, Keith Mulbery, Eric Cameron, Jason Davidson, Rebecca Lawson, Linda Lau, Jerri Williams Chapter 10 Using Macros and SQL in Access 1.
The switch Statement.  Occasionally, an algorithm will contain a series of decisions in which a variable or expression is tested separately for each.
“SAS macros are just text substitution!” “ARRRRGGHHH!!!”
1 Chapter 3: Macro Definitions 3.1 Defining and Calling a Macro 3.2 Macro Parameters 3.3 Macro Storage (Self-Study)
Microsoft® Small Basic
Chapter 10:Processing Macro Variables at Execution Time 1 STAT 541 © Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
INSERT BOOK COVER 1Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Microsoft Office Access 2010 by Robert Grauer, Keith.
1 Chapter 5: Macro Programs 5.1 Conditional Processing 5.2 Parameter Validation 5.3 Iterative Processing 5.4 Global and Local Symbol Tables.
11 Chapter 3: Reading and Processing Data 3.1 Processing SAS Data Sets 3.2 Processing External Files.
Prepared by: Luigi Muro – Consultant
INTRODUCTION TO SAS MACRO PROCESSING James R. Bence, Ph.D., Co-Director Quantitative Fisheries Center Professor Department of Fisheries and Wildlife March.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
1 Chapter 2: Macro Variables 2.1 Introduction to Macro Variables 2.2 Automatic Macro Variables 2.3 Macro Variable References 2.4 User-Defined Macro Variables.
PL/SQL vs. Transact-SQL. Transact-SQL Central to the use of Microsoft® SQL Server™. All applications that communicate with SQL Server do so by sending.
Machine Independent Macro Processor Features Concatenation of Macro Parameters Generation of Unique Labels Conditional Macro Expansion Keyword Macro.
Introduction to ABAP Selection Screens. Slide 2 Screens (Types) There are three types of screens Selection screens get parameter input for reports List.
SQL Chapter Two. Overview Basic Structure Verifying Statements Specifying Columns Specifying Rows.
Macro Variable Resolution Enio Presutto York University, Toronto, Canada.
Chapter 22: Using Best Practices 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
© OCS Biometric Support 1 APPEND, EXECUTE and MACRO Jim Groeneveld, OCS Biometric Support, ‘s Hertogenbosch, Netherlands. PhUSE 2010 – CC05 PhUSE 2010.
1 SQL - II Data Constraints –Applying data constraints Types of data constraints –I/O constraints The PRIMARY KEY constraints The FOREIGN KEY constraints.
BMTRY 789 Lecture 10: SAS MACRO Facility Annie N. Simpson, MSc.
1 Chapter 4: DATA Step and SQL Interfaces 4.1 Creating Macro Variables in the DATA Step 4.2 Indirect References to Macro Variables 4.3 Retrieving Macro.
Tips & Tricks From your fellow SAS users 9/30/2004.
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
Variables and control statements in PL\SQL Chapter 10.
Chapter 4 concerns various SAS procedures (PROCs). Every PROC operates on: –the most recently created dataset –all the observations –all the appropriate.
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
Controlling Input and Output
TASS Meeting Setting GuessingRows when Importing Excel Files September 19th, 2008 Setting GuessingRows when importing Excel Files Dr. Arthur Tabachneck,
FOR MONDAY: Be prepared to hand in a one-page summary of the data you are going to use for your project and your questions to be addressed in the project.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
IS6146 Databases for Management Information Systems Lecture 4: SQL IV – SQL Functions and Procedures Rob Gleasure robgleasure.com.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapter 25 By Tasha Chapman, Oregon Health Authority.
1 Cleaning Invalid Data. Clean data by using assignment statements in the DATA step. Clean data by using IF-THEN / ELSE statements in the DATA step. 2.
Working Efficiently with Large SAS® Datasets Vishal Jain Senior Programmer.
1 ENERGY 211 / CME 211 Lecture 3 September 26, 2008.
Chapter 5 Introduction to SQL.
Chapter 5: Passing and Processing Macro Parameters
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Two “identical” programs
2. Understanding VB Variables
Creating Macro Variables in SQL (Review)
Using the Set Operators
Conditional Processing
3 Macro Parameters.
Exploring Microsoft® Access® 2016 Series Editor Mary Anne Poatsy
Indirect References to Macro Variables
variables and control statements in PL\SQL
Creating Macro Variables in the DATA Step
Macro Variable’s scope
Format String.
Defining and Calling a Macro
Global and Local Symbol Tables
3 Iterative Processing.
Examining model stability, an example
3 Parameter Validation.
Format String Vulnerability
Presentation transcript:

Retrieving Macro Variables in the DATA Step 4 Retrieving Macro Variables in the DATA Step

Obtain the value of a macro variable during DATA step execution Obtain the value of a macro variable during DATA step execution. Describe the difference between the SYMGET function and macro variable references.

create macro variables Review create macro variables %LET

Review create macro variables retrieve macro variables %LET &macvar

Review create macro variables retrieve macro variables word scanning time %LET &macvar

Review create macro variables retrieve macro variables word scanning time %LET &macvar execution time CALL SYMPUTX

The SYMGET Function create macro variables retrieve macro variables word scanning time %LET &macvar execution time CALL SYMPUTX SYMGET(macvar)

The SYMGET Function Retrieve a macro variable’s value during DATA step execution with the SYMGET function. Symbol Table Program Data Vector DATA Step Variables SYMGET

The SYMGET Function SYMGET(macro-variable) macro-variable can be specified as either of the following: character literal DATA step character expression A DATA step variable created by the SYMGET function is a character variable with a length of 200 bytes unless it has been previously defined.

Create a series of macro variables to store customer names. data _null_; set orion.customer; call symputx('name'||left(Customer_ID), customer_Name); run; %put _user_;

The SYMGET Function Example: Look up customer names from the symbol table. data InternetCustomers; keep order_date customer_ID customer_name; set orion.order_fact; if order_type=3; length Customer_Name $ 20; Customer_Name=symget('name'||left(customer_ID)); run; proc print data=InternetCustomers; var order_date customer_ID customer_name; title "Internet Customers"; The LENGTH statement is important to avoid a default length of 200.