{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full Document Right Arrow Icon
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
Background image of page 2
3 Objectives Create macro variables during DATA step execution. Describe the difference between the SYMPUTX routine and the %LET statement.
Background image of page 3

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

View Full Document Right Arrow Icon
4 The DATA Step Interface 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
Background image of page 4
5 The DATA Step Interface %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
Background image of page 5

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

View Full Document Right Arrow Icon
6 The DATA Step Interface 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
Background image of page 6
7 The DATA Step Interface %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
Background image of page 7

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

View Full Document Right Arrow Icon
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 Compiling begins. Macro variable references are resolved. ... Symbol Table
Background image of page 8
9 The DATA Step Interface 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 macro trigger is passed to the macro processor.
Background image of page 9

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

View Full Document Right Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}