mac1c04 - 1 Chapter 4: DATA Step and SQL Interfaces 4.1...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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 Variables in the DATA Step (Self-Study) 4.4 Creating Macro Variables in SQL 2 Chapter 4: DATA Step and SQL Interfaces 4.1 Creating Macro Variables in the DATA Step 4.1 Creating Macro Variables in the DATA Step 4.2 Indirect References to Macro Variables 4.3 Retrieving Macro Variables in the DATA Step (Self-Study) 4.4 Creating Macro Variables in SQL 3 Objectives Create macro variables during DATA step execution. Describe the difference between the SYMPUTX routine and the %LET statement. 3 4 The DATA Step Interface 4 Example: Automate production of the report below, with an appropriate footnote. Internet orders have an Order_Type of 3 . Orders for 2-2007 Order_ Order_ Total_Retail_ Obs Date Type Quantity Price 1 05FEB2007 1 1 $117.60 2 07FEB2007 1 2 $656.60 3 07FEB2007 1 2 $129.00 4 09FEB2007 1 2 $36.20 5 16FEB2007 1 1 $29.40 6 28FEB2007 1 5 $192.00 No Internet Orders 5 The DATA Step Interface 5 %let month=2; %let year=2007; data orders; keep order_date order_type quantity total_retail_price; set orion.order_fact end=final; where year(order_date)=&year and month(order_date)=&month; if order_type=3 then Number+1; if final then do; put Number=; if Number=0 then do; %let foot=No Internet Orders; end; else do; %let foot=Some Internet Orders; end; end; run; proc print data=orders; title "Orders for &month-&year"; footnote "&foot"; run; m104d01a 6 The DATA Step Interface 6 Why is the footnote incorrect? Orders for 2-2007 Order_ Order_ Total_Retail_ Obs Date Type Quantity Price 1 05FEB2007 1 1 $117.60 2 07FEB2007 1 2 $656.60 3 07FEB2007 1 2 $129.00 4 09FEB2007 1 2 $36.20 5 16FEB2007 1 1 $29.40 6 28FEB2007 1 5 $192.00 Some Internet Orders 7 The DATA Step Interface 7 %let month=2; %let year=2007; data orders; keep order_date order_type quantity total_retail_price; set orion.order_fact end=final; where year(order_date)=&year and month(order_date)=&month; if order_type=3 then Number+1; if final then do; put Number=; if Number=0 then do; %let foot=No Internet Orders; end; else do; %let foot=Some Internet Orders; end; end; run; Word scanning begins. Macro triggers are encountered. ... Symbol Table month 2 year 2007 8 data orders; keep order_date order_type quantity total_retail_price; set orion.order_fact end=final; where year(order_date)=2007 and month(order_date)=2; if order_type=3 then Number+1; if final then do; put Number=; if Number=0 then do; %let foot=No Internet Orders; end; else do; %let foot=Some Internet Orders; end; end; run; The DATA Step Interface month 2 year 2007 8 Compiling begins. Macro variable references are resolved....
View Full Document

This note was uploaded on 02/20/2012 for the course STAT 506 taught by Professor Staff during the Fall '08 term at Purdue.

Page1 / 105

mac1c04 - 1 Chapter 4: DATA Step and SQL Interfaces 4.1...

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

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