{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

mac1c04

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

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

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

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

View Full Document
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.

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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
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.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}