Hi all, I'm not very experienced with Macro language so any assistance will be greatly appreciated. I have a series of proc sql statements which pull data for Active, Inactive and Lapsed customers. I end up with 3 tables. *Customers_Active *Customers_InActive *Customers_Lapsed Active: 0-12M purchaser Inactive: 13-24M purchaser, did not purchase 0-12M (active day range minus 12 months) Lapsed: 25-36M purchaser, did not purchase 0-24M (inactive day range minus 24 months) Again, In order to do this I have 3 separate proc sql statements and I start out by defining 6 macro variables. I want to apply macro language so I can uses just 1 query to produce the 3 tables. %let actstart = '24Feb2013'd ; %let actend = '22Feb2014'd; %let iactstart = '26Feb2012'd; %let iactend= '23Feb2013'd; %let lapstart = '27Feb2011'd ; %let lapend = '25Feb2012'd; Here are the three statements /*Active Table*/ proc sql; create table Customers_Active as select household_id, customer_id, web_order_id, transaction_date, sku, quantity, original_price from transaction_vw where transaction_date >= &actstart and transaction_date <= &actend order by customer_id; quit; /*Inactive Table*/ Notice I am not bringing in the customer_id which is already in the Customers_Active table. This tricky when writing the macro. proc sql; create table Customers_Inactive as select household_id, customer_id, web_order_id, transaction_date, sku, quantity, original_price from transaction_vw wheretransaction_date >= & iactstart and transaction_date <= &iactend and customer_id not in (select distinct customer_id from Customers_Active) order by customer_id; quit; /*Lapsed Table*/ Notice I am not bringing in the customer_id which is not already in the Customers_Active and the Customers_Inactive table. Again, this tricky when writing the macro. proc sql; create table Customers_Lapsed as select household_id, customer_id, web_order_id, transaction_date, sku, quantity, original_price from transaction_vw wheretransaction_date >= & lapstart and transaction_date <= & lapend and customer_id not in (select distinct customer_id from Customers_Active) and customer_id not in (select distinct customer_id from Customers_Inactive) order by customer_id; quit; Again, any help is greatly appreciated. Thanks!
... View more