Presentation is loading. Please wait.

Presentation is loading. Please wait.

Retrieving Macro Variables in the DATA Step

Similar presentations


Presentation on theme: "Retrieving Macro Variables in the DATA Step"— Presentation transcript:

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

2 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.

3 create macro variables
Review create macro variables %LET

4 Review create macro variables retrieve macro variables %LET &macvar

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

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

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

8 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

9 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.

10 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_;

11 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.


Download ppt "Retrieving Macro Variables in the DATA Step"

Similar presentations


Ads by Google