proc sql noprint; create table &abt_worklib..input_plan_rules_1 as select trim(lowcase(a.pricing_plan_id)) as pricing_plan_id length=37, trim(lowcase(a.business_category_id)) as business_category_id label='business_category_id' length=37, &gv_current_dt. as current_date format=&gv_rd_date_sas_format. label='current_date', %if %length(&init_rec_promo_dt) eq 0 %then %do; . as initial_rec_date_promo format=&gv_rd_date_sas_format. label='initial_rec_date_promo', %end; %else %do; &init_rec_promo_dt. as initial_rec_date_promo format=&gv_rd_date_sas_format. label='initial_rec_date_promo', %end; %if %length(&last_rec_dt_promo) eq 0 %then %do; . as last_rec_date_promo format=&gv_rd_date_sas_format. label='last_rec_date_promo', %end; %else %do; &last_rec_dt_promo. as last_rec_date_promo format=&gv_rd_date_sas_format. label='last_rec_date_promo', %end; /*2 as opt_flag format=1. length=3,*/ &opt_flag. as opt_flag format=1. length=3, '' as promo_period length=500 informat=$500. format=$500., case when input(b.rule_val_1525,1.) = 0 then 5 when input(b.rule_val_1525,1.) = 1 then 4 when input(b.rule_val_1525,1.) = 2 then 1 else 0 end as obj_func_promo format=3. length=3, input(b.rule_val_1404,1.) as promo_price_grid_type format=1. length=3, input(b.rule_val_1301,1.) as is_inventory_constrained format=1. length=3, input(b.rule_val_1302,best9.) as min_discount_pct_promo format=&gv_rd_pct_sas_format., input(b.rule_val_1303,best9.) as max_discount_pct_promo format=&gv_rd_pct_sas_format., case when input(b.rule_val_1306,1.) = 1 then input(b.rule_val_1304,best9.) else . end as min_margin_pct_promo format=&gv_rd_pct_sas_format., case when input(b.rule_val_1306,1.) = 2 then input(b.rule_val_1304,best18.) else . end as min_margin_promo format=&gv_rd_amt_sas_format., case when input(b.rule_val_1306,1.) = 1 then input(b.rule_val_1305,best9.) else . end as max_margin_pct_promo format=&gv_rd_pct_sas_format., case when input(b.rule_val_1306,1.) = 2 then input(b.rule_val_1305,best18.) else . end as max_margin_promo format=&gv_rd_amt_sas_format., case when input(b.rule_val_1526,1.) = 1 then input(b.rule_val_1503,best18.) else . end as gross_margin_lb_promo format=&gv_rd_amt_sas_format., case when input(b.rule_val_1526,1.) = 1 then input(b.rule_val_1504,best18.) else . end as gross_margin_ub_promo format=&gv_rd_amt_sas_format., case when input(b.rule_val_1526,1.) = 0 or input(b.rule_val_1526,1.) = . then . else . end as gross_margin_lb_promo format=&gv_rd_amt_sas_format., case when input(b.rule_val_1526,1.) = 0 or input(b.rule_val_1526,1.) = . then . else . end as gross_margin_ub_promo format=&gv_rd_amt_sas_format., case when input(b.rule_val_1527,1.) = 1 then input(b.rule_val_1505,best18.) else . end as sell_through_units_lb_promo format=&gv_rd_qty_sas_format., case when input(b.rule_val_1527,1.) = 1 then input(b.rule_val_1506,best18.) else . end as sell_through_units_ub_promo format=&gv_rd_qty_sas_format., case when input(b.rule_val_1527,1.) = 0 or input(b.rule_val_1527,1.) = . then . else . end as sell_through_units_lb_promo format=&gv_rd_qty_sas_format., case when input(b.rule_val_1527,1.) = 0 or input(b.rule_val_1526,1.) = . then . else . end as sell_through_units_ub_promo format=&gv_rd_qty_sas_format., case when input(b.rule_val_1528,1.) = 1 then input(b.rule_val_1501,best18.) else . end as gross_margin_lb_promo format=&gv_rd_amt_sas_format., case when input(b.rule_val_1528,1.) = 1 then input(b.rule_val_1502,best18.) else . end as gross_margin_ub_promo format=&gv_rd_amt_sas_format., case when input(b.rule_val_1528,1.) = 2 then input(b.rule_val_1507,best18.) else . end as gross_margin_pct_lb_promo format=&gv_rd_qty_sas_format., case when input(b.rule_val_1528,1.) = 2 then input(b.rule_val_1508,best18.) else . end as gross_margin_pct_ub_promo format=&gv_rd_qty_sas_format., case when input(b.rule_val_1528,1.) = 0 or input(b.rule_val_1528,1.) = . then . else . end as gross_margin_pct_ub_promo format=&gv_rd_qty_sas_format., 1 as allow_manual_mkd format=1. length=3, 1 as allow_manual_promo_on_reg_price format=1. length=3, 1 as allow_stacked_promo_on_mkd format=1. length=3, 1 as allow_stacked_promo_on_promo format=1. length=3, 1 as allow_promo_price_below_mpp format=1. length=3, input(b.rule_val_1508,best9.) as gross_margin_pct_ub_promo format=&gv_rd_qty_sas_format. /*input(b.rule_val_516,6.) as min_periods_since_avail_dt format=&gv_rd_cnt_sas_format.*/ from &abt_worklib..pricing_plan a left join &abt_worklib..plan_rule_transposed b on upcase(a.pricing_plan_id) = upcase(b.pricing_plan_id) left join &pricing_lib..date_dm e on a.end_dt between e.fiscal_start_dt and e.fiscal_end_dt and e.date_lvl_no = &time_low_lvl. ; quit;
... View more